allow palette.qualitative specification via function#594
Conversation
|
Thanks @zeileis. I did some testing and it mostly looks good. The one exception was for passing tinyplot(
1:10,
by = 1:10,
theme = list(palette.sequential = my_pal)
)Would it work to change l. 304 here Line 304 in 4ef61ae to pal_theme = if (ordered || gradient) {
get_tpar("palette.sequential", default = NULL) %||% get_tpar("palette.qualitative", default = NULL)
} else {
get_tpar("palette.qualitative", default = NULL)
}? (I haven't tested) |
|
Makes sense. I have omitted the Should we add the analogous computation in |
Good call. I can't think of a reason not to. |
|
@zeileis once the |
|
I added the same palette handling in Also added some tinytests/snapshots. |
Thanks. If memory serves, this example was failing earlier but is working now. my_pal = colorRampPalette(c("red", "yellow", "blue"))
i = 4*(0:10)
tinyplot(
xmin = 100+i, ymin = 300+i, xmax = 150+i, ymax = 380+i,
by = i, fill = 0.2,
type = "rect",
theme = list("default", palette.sequential = my_pal)
)Either way, agree that having some backup/redundancy doesn't hurt. P.S. I'm not sure why the added snapshot tests are failing on the CI. I just tested locally and everything is passing, so it might be an annoying false positive case. I have to step out for a bit, but can investigate when I"m back. |
|
Figured it out; just an innocuous main branch difference. |
|
Excellent, thanks for the example and for fixing the CI failure! 💪 |
Fixes #593
In order to support function specifications of
palette.qualitativein themes, I think that we only need to make sure thatmatch_palette_name(theme_palette, ...)is only used iftheme_paletteis a character string (but not a function).Then both
palette.qualitativeandpalette.sequentialcan be a function in a theme: