p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point()
p
old <- theme_set(theme_bw())
p
theme_set(old)
p
#theme_replace NULLs out the fill attribute of panel.background,
#resulting in a white background:
theme_get()$panel.background
old <- theme_replace(panel.background = element_rect(colour = "pink"))
theme_get()$panel.background
p
theme_set(old)
#theme_update only changes the colour attribute, leaving the others intact:
old <- theme_update(panel.background = element_rect(colour = "pink"))
theme_get()$panel.background
p
theme_set(old)
theme_get()
ggplot(mtcars, aes(mpg, wt)) +
geom_point(aes(color = mpg)) +
theme(legend.position = c(0.95, 0.95),
legend.justification = c(1, 1))
last_plot() +
theme(legend.background = element_rect(fill = "white", colour = "white", size = 3))
Run the code above in your browser using DataLab