MatthewBJane / ThemePark

Fun ggplot themes for popular culture
http://matthewbjane.com/ThemePark/
MIT License
196 stars 13 forks source link

Handling Exported Color Names #18

Closed christopherkenny closed 11 months ago

christopherkenny commented 1 year ago

Currently, colors are defined as variables in the environment. This works well for sourcing a script. This does not work so well for a package namespace. As you can imagine, if each theme has say 8 colors then at 17 existing themes, we have 136 colors that would need to be documented. This type (a) pollutes the search path, making it harder to use autocomplete and (b) gets out of control fast.

Solution A: Export 2 lists, one with theme colors and one with discrete color palettes

This would look like defining a common list with common names (a la #11)

theme_park <- list(
    barbie = c(text_color= '#a62675ff', panel_color = '#fdf6faff', border_color = '#d74ea2ff', 
                      lighter_color = '#f5d1e6ff', light_color = '#eeb4d7ff', medium_color = '#d74ea2ff', 
                      dark_color= '#bf2986ff'),
  ...
)

and a second common list for discrete color palettes:

theme_palettes <- list(
    nemo = c(
      '#E9F4FB', '#FE691D', '#015DC2', '#FCDD2E', '#7867A0',
      '#BE1D57', '#798A5A', '#005478','#1B1A3D'
    ), 
...
)

Solution B: Have two color vectors for each

Theme colors would be added to the theme Rd and might look like:

theme_barbie_colors <- c(text_color= '#a62675ff', panel_color = '#fdf6faff', border_color = '#d74ea2ff', 
                      lighter_color = '#f5d1e6ff', light_color = '#eeb4d7ff', medium_color = '#d74ea2ff', 
                      dark_color= '#bf2986ff')

Colors that you might want to use within plots would be added to the scale Rd and might look like:

nemo_colors <- c(
  '#E9F4FB', '#FE691D', '#015DC2', '#FCDD2E', '#7867A0',
  '#BE1D57', '#798A5A', '#005478','#1B1A3D'
)

Solution C:

Don't export colors. This is the easiest, but probably the least fun.


Of course, we can also mix and match, but probably want to pick something consistent that is maintainable.

MatthewBJane commented 1 year ago

I think solution B might be the way to go? Although if there is a good reason to go with A then I am not opposed. Its probably pretty straight-forward to change what we currently have (although a bit tedious). Also, I think the default labels for the themes should probably go like:

primary secondary tertiary text border panel background

I think the contributors were not following the lighter-light-medium-dark scheme I was initially going for so we can drop that.