Provides a base plot theme for ggplot2 to match the xaringan slide theme
created by xaringanthemer. The theme is designed to create a general plot
style from two colors, a background_color and a text_color (or foreground
color). Also accepts an accent_color and an accent_secondary_color that are
xaringanthemer is not required for the base theme. Use
theme_xaringan() or theme_xaringan_inverse() in xaringan slides styled by
xaringanthemer for a plot theme that matches the slide style.
theme_xaringan_base(text_color, background_color, ..., set_ggplot_defaults = TRUE, accent_color = NULL, accent_secondary_color = NULL, text_font = NULL, text_font_use_google = NULL, text_font_size = NULL, title_font = NULL, title_font_use_google = NULL, title_font_size = NULL)
| text_color | Color for text and foreground |
|---|---|
| background_color | Color for background |
| ... | Ignored |
| set_ggplot_defaults | Should defaults be set for ggplot2 geoms?
Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
defaults, see |
| accent_color | Color for titles and accents, inherits from
|
| accent_secondary_color | Color for secondary accents, inherits from
|
| text_font | Font to use for text elements, passed to
|
| text_font_use_google | Is |
| text_font_size | Base text font size, inherits from |
| title_font | Font to use for title elements, passed to
|
| title_font_use_google | Is |
| title_font_size | Base text font size, inherits from |
A ggplot2 theme
Other xaringanthemer ggplot2 themes: theme_xaringan_inverse,
theme_xaringan_set_defaults,
theme_xaringan
if (requireNamespace("ggplot2", quietly = TRUE)) { library(ggplot2) ggplot(iris) + aes(Petal.Length, Petal.Width) + geom_point() + theme_xaringan_base( text_color = "#e1e5f2", background_color = "#021c25", accent_color = "#1f7a8c", set_ggplot_defaults = TRUE) + labs(title = "Basic Iris Plot", subtitle = "+ theme_xaringan_base()", caption = "{xaringanthemer}") ggplot(iris) + aes(Petal.Length, Petal.Width) + geom_point() + theme_xaringan_base( text_color = "#021c25", background_color = "#e1e5f2", accent_color = "#1f7a8c", set_ggplot_defaults = TRUE) + labs(title = "Basic Iris Plot", subtitle = "+ theme_xaringan_base()", caption = "{xaringanthemer}") }#> Error in search_db(name, db_cache, handle): font not found