-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a theme_palette()
function
#16
Comments
Ooh, this is an interesting idea! I'm about to use {palettes} to make a package with my university's brand colours (The University of Warwick), and was planning on adding a |
GoalI’m pretty open on what this will look like, but my original thought was a function like: theme_palette(palette, …) Or maybe several Regardless, the basic idea is that you supply a palette to change the colour of multiple elements of a theme together. It’s a convenience function so you don’t need to write out all the Exampleggprism does this, but there they provide premade palettes and the user just picks the one they want by name: https://cran.r-project.org/web/packages/ggprism/vignettes/themes.html#theme-palettes. I wanted to generalize this idea—where the user provides a palette and the function “smartly” colours elements based on the number of colours in the palette. For example, if a palette had one colour, then that colour would be applied to all theme elements (axis lines, ticks, etc.); but if it had more than one colour then colours would be applied more selectively to certain elements (maybe the first colour would go to axis elements, the second to gridlines, or something like that). Which elements get grouped together and given the same colour would be an opinionated decision. There would also be an upper limit on the maximum number of colours from a palette that would actually be used, probably in the 2-4 range. APII think it would be a good idea to handle the background and text colour separately from the Other inspirationthematic provides an interesting approach to overriding ggplot themes based on bootstrap theme elements. I haven’t dug into how it works, but some of the ideas used there might work nicely for deciding which theme elements to group together with the same colour, a max colour limit, etc. It also works with custom themes: https://rstudio.github.io/thematic/articles/custom.html It may also mean a Cool talk! And let me know how your package goes 😄 |
Where you supply a palette and it colours theme elements based on the number of colours in the palette (e.g., if 1 colour, all elements take on that colour, if 2 then colour 1 is the primary and colour 2 is the secondary, etc.).
theme_prism
fromggprism
does something similar (picking a theme based on a palette): https://cran.r-project.org/web/packages/ggprism/vignettes/themes.html, https://github.com/csdaw/ggprism/blob/master/R/theme_prism.RThe text was updated successfully, but these errors were encountered: