Hi there,
I was wondering if there is any possibility to have a conditional theme for ggplot2.
I have created a theme for my package to visualize results, which can either be continuous or discrete.
It returns a list with the theme and a color scale (viridis in this case), like so:
theme_test <- function() {
# start with minimal theme
ret <-
ggplot2::theme_minimal()
# extend it
theme_base <- ret + ggplot2::theme()
# define color scale
theme_color <- viridis::scale_fill_viridis()
# return as list
list(theme_base,
theme_color)
}
The scale should then either be discrete or continuous, depending on the input data and without the need to specify that in every case.
... is there any way to access the inherited data with the .
operator?
Maybe as a function in the theme arguments (like waiver?) or in the function declaration of theme_test
?