GiovineItalia / Gadfly.jl

Crafty statistical graphics for Julia.
http://gadflyjl.org/stable/
Other
1.9k stars 250 forks source link

Fine grained theme settings #1458

Open llrt opened 4 years ago

llrt commented 4 years ago

Hi,

First, I would like to thank and congratulate everyone involved for this neat, amazing package! Nice job, guys!

I would like to reproduce in my plots in Gadfly a ggplot BBC-like style (https://github.com/bbc/bbplot/blob/master/R/bbc_style.R), but current settings differs a lot in detail. My current pains and suggestions are:

Thank you all!

Mattriks commented 4 years ago

Can you give an example of what you are trying to do in your 3rd dotpoint? It's definitely possible to mix Compose graphics and Gadfly plots.

llrt commented 4 years ago

@Mattriks I would like to do something along those lines below in R (example from bbplot repo):

axis.ticks = ggplot2::element_blank(),

axis.line = ggplot2::element_blank(),

panel.grid.major.y = ggplot2::element_line(color="#cbcbcb"),

strip.background = ggplot2::element_rect(fill="white"),

strip.text = ggplot2::element_text(size = 22, hjust = 0)

Basically. when element_text is present, a label is drawn; when element_blank is present, that block is suppressed. And you can add other elements, like lines, logos, etc.

Mattriks commented 3 years ago

For text, this would be easy to implement:

  1. Add 5 new Theme fields: major_label (or major_label_text), minor_label, point_label, key_title, key_label, which will accept the new struct in 2.
  2. Create a new struct e.g. struct TextFormat with fields font, fontsize, color, padding etc.
  3. Mark old Theme fields (major_label_font etc) for deprecation
  4. Update code for Guides, e.g. Guide.xlabel, Guide.ylabel etc allowing a transition to the new Theme fields.

I think this is a nicer syntax, and has some advantages (easy to add new fields e.g. padding #1514)

Comments? Name suggestions for the new struct in 2 welcome!

llrt commented 3 years ago

For text, this would be easy to implement:

  1. Add 5 new Theme fields: major_label (or major_label_text), minor_label, point_label, key_title, key_label, which will accept the new struct in 2.
  2. Create a new struct e.g. struct TextFormat with fields font, fontsize, color, padding etc.
  3. Mark old Theme fields (major_label_font etc) for deprecation
  4. Update code for Guides, e.g. Guide.xlabel, Guide.ylabel etc allowing a transition to the new Theme fields.

I think this is a nicer syntax, and has some advantages (easy to add new fields e.g. padding #1514)

Comments? Name suggestions for the new struct in 2 welcome!

Nice suggestion! I think this shall address many points in the original request, making the API cleaner. I agree with suggested approach.