add_pilot_titles: Add titles to a plot using the pilot theme style

View source: R/themes.R

add_pilot_titlesR Documentation

Add titles to a plot using the pilot theme style

Description

Use this function to add titles to a plot that uses theme_pilot. Using this functin to set the title and/or subtitle will ensure that title elements are aligned with the left-hand edge of the y-axis text, rather than the left-hand edge of the plotting area.

Usage

add_pilot_titles(
  plot,
  title = NULL,
  subtitle = NULL,
  title_family = getOption("pilot.title_family"),
  subtitle_family = getOption("pilot.subtitle_family"),
  title_size = 17,
  subtitle_size = 12,
  title_color = "#404040",
  subtitle_color = "#404040",
  background_color = "#ffffff"
)

Arguments

plot

A ggplot2 plot object to which titles will be added.

title

A string containing the title to add to the plot. Use NULL if you do not want a title.

subtitle

A string containing the subtitle to add to the plot. Use NULL if you do not want a subtitle.

title_family

A string indicating the font-family to use for the title. The default depends on the operating system.

subtitle_family

A string indicating the font-family to use for the subtitle. The default depends on the operating system.

title_size

An integer indicating the font size to use for the title in points. The default is 17 points.

subtitle_size

An integer indicating the font size to use for the subtitle in points. The default is 12 points.

title_color

An RGB hex string indicating the color to use for the title. The default is "#404040".

subtitle_color

An RGB hex string indicating the color to use for the subtitle. The default is "#404040".

background_color

An RGB hex string indicating the color to use for the background. The default is "#ffffff".

Details

To use the function, first create a plot using theme_pilot without setting the title or subtitle, capturing the plot object in a variable. Pass the plot to add_pilot_titles along with the title and subtitle you want to use. This function will return the same plot with titles added to the top and the correct spacing between the titles and the rest of the plot area.

Arguments are also available to set the font properties of the title and subtitle elements of the plot.

Value

A copy of the input plot with a title and/or subtitle added.


olihawkins/pilot documentation built on July 21, 2022, 9:48 a.m.