apply_scaling: Size scaling for plots with customized theme

View source: R/theme_cr.R

apply_scalingR Documentation

Size scaling for plots with customized theme

Description

This function applies only the size-based theme modifications from the theme_cr() function. It does not include %+replace%, so it can be applied on top of pre-existing theme modifications (e.g., the theme_cut() functions).

Usage

apply_scaling(plot_scale = 1, font_scale = 1, set_margin = TRUE)

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.

set_margin

Flag for whether or not to change the plot margin from the baseline. Used as a separate option because it is difficult to specifically adjust when plots are combined.

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

# Multiply height and width of the plot by 2
p + theme_cr() + apply_scaling(plot_scale = 2)

# Divide height and width of plot by 2 but keep original font size
p + theme_cr() + apply_scaling(plot_scale = 0.5, font_scale = 2)

# Multiply height and width of the plot by 2 but do not change the margins
p + theme_cr() + apply_scaling(plot_scale = 2, set_margin = FALSE)

## End(Not run)

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