theme_cr: Base customized theme

View source: R/theme_cr.R

theme_crR Documentation

Base customized theme

Description

The default customized theme for figure creation. This is also used as the base theme for additional modifications, such as for bar graphs and heat maps.

Usage

theme_cr(
  plot_scale = 1,
  font_scale = 1,
  font = "Roboto Regular",
  symbol = TRUE,
  cairo = FALSE
)

Arguments

plot_scale

Scaling factor for the plot components as a whole. A value of 1 corresponds to a font size of 12 pt and a figure size of 6" by 4"

font_scale

Scaling factor for the font as compared to the plot. A value of 1 will scale the font to the plot size. Larger numbers make the font large compared to the plot size; smaller numbers make the font small compared to the plot size.

font

Font family to be used in the theme, 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, theme_cr() will overwrite the Symbol font, and this change will persist until the end of the R session or until clear_registry() is used.

cairo

Is a cairographics device being used to save the figure? ("pdf" and "eps" filetypes) Cairo does not use the font registration from the systemfonts package, so an alternate cairo-safe font must be provided and the normal font registration will be skipped.

Details

This builds off of the theme_gray function from the ggplot2 package. It overrides components of the theme_gray function with the function-specified components, resulting in a completely custom theme. It uses the packaged fonts by default.

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()

## Not run: 
p + theme_cr() # Uses default scaling and font
p + theme_cr(font = "Roboto Medium") # Bolder font
p + theme_cr(plot_scale = 2) # Multiply height and width of the plot by 2
p + theme_cr(font = "Roboto Medium", symbol = FALSE) # Use system Symbol font
p + theme_cr(font = "Avenir", cairo = TRUE) # Use a cairo-safe font

## End(Not run)

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