ggplot2_theme_html: Add common HTML-specific theme to ggplot2 chart

ggplot2_theme_htmlR Documentation

Add common HTML-specific theme to ggplot2 chart

Description

Dynamically adds common HTML-specific theming to a ggplot2 chart. It depends on the current knitr output format whether the additional HTML-specific theming is actually added or not.

Usage

ggplot2_theme_html(
  .color_text = pal::pkg_config_val(key = "plot_color_body", pkg = this_pkg),
  .color_bg = pal::pkg_config_val(key = "plot_color_bg", pkg = this_pkg),
  .color_grid = pal::pkg_config_val(key = "plot_color_grid", pkg = this_pkg),
  ...
)

Arguments

.color_text

Text color to use for all text elements (ggplot2::element_text()) when the knitr output format is HTML.

.color_bg

Background color to use when the knitr output format is HTML.

.color_grid

Grid color to use when the knitr output format is HTML.

...

Further arguments passed on to ggplot2::theme() when the knitr output format is HTML.

Details

Note that ggplot2_theme_html() must be evaluated during knitting to work properly.

Value

An object of class theme.

See Also

Other plot theming functions: ggplot2_geom_defaults(), ggplot2_theme(), plotly_layout()

Examples

sysfonts::font_add_google(name = "Alegreya Sans")
showtext::showtext_auto()

ggplot2::ggplot(data = mtcars,
                mapping = ggplot2::aes(x = mpg,
                                       y = cyl)) +
  ggplot2::geom_point() +
  salim::ggplot2_theme() +
  salim::ggplot2_theme_html()

salim-b/salim documentation built on Aug. 1, 2024, 8:57 p.m.