Skip to contents

Changes only the family of text elements on a ggplot, preserving size, face, colour, margins, and element classes. When an element is missing and needs to be created (scope = "all_listed"), it is cloned from the current/global theme first so sizes never reset.

Usage

apply_period_fonts(
  p,
  era = "journal-1960s",
  scope = c("base_only", "targeted", "all_listed"),
  install_if_missing = TRUE,
  use_showtext = FALSE
)

Arguments

p

A ggplot.

era

One of: "journal-1930s","journal-1960s","slide-1970s", "slide-1980s","typewriter-1950s","handdrawn-pen".

scope

"base_only" (only text), "targeted" (also title/subtitle/caption, axis/strip/legend if they already exist), or "all_listed" (force-create any missing listed elements by cloning a template).

install_if_missing, use_showtext

See .period_families().

Value

The modified ggplot.

Examples

if (FALSE) { # \dontrun{
if (requireNamespace("ggplot2", quietly = TRUE)) {
  p <- ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) + ggplot2::geom_point()
  apply_period_fonts(p)
}
} # }