theme_update {animint2}R Documentation

Get, set and update themes.

Description

Use theme_get to get the current theme, and theme_set to completely override it. theme_update and theme_replace are shorthands for changing individual elements in the current theme. theme_update uses the + operator, so that any unspecified values in the theme element will default to the values they are set in the theme. theme_replace will completely replace the element, so any unspecified values will overwrite the current value in the theme with NULLs.

Usage

theme_update(...)

theme_replace(...)

theme_get()

theme_set(new)

Arguments

...

named list of theme settings

new

new theme (a list of theme elements)

See Also

%+replace%

Examples

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))


[Package animint2 version 2024.1.24 Index]