| gg_theme | R Documentation |
Constructs a ggplot2 theme by resolving a base theme, then merging colour
and font overrides – exactly mirroring what hd_theme() does for the
highcharter backend.
gg_theme(theme = NULL, colors = NULL, font = NULL)
theme |
Character name string, ggplot2 theme object, or |
colors |
Character vector, palette name string, or |
font |
Character or |
Priority for each argument:
theme: explicit argument > getOption("highdir.gg_theme") > "classic"
colors: explicit argument > getOption("highdir.colors") > NULL
font: explicit argument > getOption("highdir.font") > NULL
Called automatically inside ggplot_engine(); also useful for applying the
package theme to a ggplot built outside highdir.
Built-in name strings and their ggplot2 equivalents:
| Name | ggplot2 function |
"classic" (default) | theme_classic() |
"minimal" | theme_minimal() |
"bw" | theme_bw() |
"light" | theme_light() |
"dark" | theme_dark() |
"void" | theme_void() |
"grey" / "gray" | theme_grey() |
An object of class "hd_gg_theme" - a list with two fields:
$theme (a ggplot2 theme object with font baked in) and $colors
(a resolved character vector or NULL). ggplot_engine() unpacks
both. The object can also be added directly to a ggplot with +
via the +.gg method (only the theme is applied; colors are handled
separately by apply_gg_colors()).
gg_theme() # session defaults
gg_theme("bw") # theme_bw(), session colors/font
gg_theme("classic", colors = c("#025169", "#7C145C"))
gg_theme("minimal", font = "Source Sans Pro")
gg_theme(ggplot2::theme_bw(base_size = 14), font = "mono")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.