Hi @mattwarkentin,
Thanks for your reply!
I got as far as you did, using a function to check if the user is using theme_grey() (the ggplot default) or not, and if so, changing it to theme_minimal(). This works as a workaround for all users who have used theme_set() with a theme other than theme_grey(). For those users, the function produces the ggplot in their preferred theme. For users who didn't set a theme, the plot will be produced with theme_minimal(). However, some of the users who didn't set a theme actually will want their plots in theme_grey() and they no longer have the option to use theme_set(theme_grey()) to set the theme for their plots globally, they will need to use + theme_grey() with every plot they produce, which is not ideal.
func <- function() {
p <- mtcars %>%
ggplot() +
aes(x = wt, y = mpg) +
geom_point()
if (identical(theme_get(), theme_grey())) {
p <- p + ggplot2::theme_minimal()
return(p)
} else {
return(p)
}
}