fix_bold: Reapply the bold font to titles and axes that contain...

View source: R/theme_helpers.R

fix_boldR Documentation

Reapply the bold font to titles and axes that contain formatted math text

Description

Formatted math text ignores the face argument of element_text() and is only styled in bold if the plotmath function bold() is used. To work around that limitation for the various titles in the plot, this function applies the font family that is one step "more bold" to the titles.

Usage

fix_bold(font = "Roboto Regular", symbol = TRUE)

Arguments

font

Font family that was used in theme_cr(), given as a character vector. The font must be included in the theme fonts; use font_names() to see a list of included fonts and font_preview() to preview a selected font.

symbol

Should the theme overwrite the system default Symbol font with the theme default font? If TRUE, fix_bold() will overwrite the Symbol font with the bolded font, and this change will persist until the end of the R session or until clear_registry() is used.

Details

The required font will be added to the current R session's font registry if is had not been already (see registry_fonts()). The required font must be included with the theme.

Value

A list containing the theme properties.

Examples

library(ggplot2)

df <- data.frame(x = 1:5, y = 1:5, z = c("a", "b", "c", "b", "c"))
p <- ggplot(df, aes(x, y, color = z)) +
  geom_point() +
  labs(
  x = bquote(Delta ~ log[10]("Parameter")),
  y = "Y-Axis Label",
  color = "Legend",
  subtitle = "Subtitle Text",
  caption = "Caption Text",
  tag = "A",
  title = bquote(alpha ~ "Regular Text" ~ 1/3)
)

## Not run: 
p + theme_cr() # Uses default scaling and font
p + theme_cr(font = "Roboto Medium") # Bolder font

## End(Not run)

christyray/crthemes documentation built on April 14, 2023, 11:18 p.m.