Closed kohske closed 9 years ago
There is nothing built in to the package yet, but it is coming. I was planning to add a function that will let you temporarily apply a theme, e.g. something like:
ggthemr_temp({
ggplot(input, aes(x, y)) +
geom_point()
}, palette = 'fresh')
Or something like that. The idea being that it will only apply the theme to the expression or function provided. And I will also look into doing it how you have in your example, with a ggthemr_reset()
type function.
Thanks for your reply. I really like this package. With ggplot2, changing/reverting theme is very easy, while changing/reverting defaults of scales/geoms is quite hard. This is a kind of hack but too bad hack...
I'll let you know if i come up with better solution.
library(ggthemr)
# default
qplot(1:3, 1:3, colour = factor(1:3))
# light theme
ggthemr("light")
qplot(1:3, 1:3, colour = factor(1:3))
# reset
detach("package:ggplot2", unload = T, force=T)
rm(list = ls(pattern = "^scale_.*"))
library(ggplot2)
qplot(1:3, 1:3, colour = factor(1:3))
That's clever, I hadn't though of doing it like that. I was planning to use update_geom_defaults()
to reset back to the original defaults, but there would probably be a lot of work involved and less guarantee the theme is properly reset.
I wish ggplot had an update_scale_defaults()
. At the moment, as you're obviously aware from your solution above, I have to put the scale functions (scale_fill_manual()
, scale_colour_continuous()
etc.) in the user's global environment. This is a bit messy I think because if someone does e.g. rm(list = ls())
the theme set by ggthemr is sort of half unset since the scale functions will disappear but the geom defaults won't. I don't know any other way around that though.
Do you have any ideas? I thought if there was a better way of assigning the scale functions, I might be able to come up with a nicer ggthemr_reset()
, but I don't think it can be done any other way unfortunately.
Is there a simple way to reset all settings to default? e.g.,