Skip to contents

This theme is designed to be a foundation from which to build new themes, and not meant to be used directly. theme_foundation() is a complete theme with only minimal number of elements defined. It is easier to create new themes by extending this one rather than ggplot2::theme_gray() or ggplot2::theme_bw(), because those themes define elements deep in the hierarchy.

Usage

theme_foundation(
  base_size = 12,
  base_family = "",
  ink = "black",
  paper = "white",
  accent = "#3366FF",
  header_family = NULL
)

Arguments

base_size

base font size, given in pts.

base_family

base font family

ink, paper, accent

colour for foreground, background, and accented elements respectively.

header_family

font family for titles and headers. The default, NULL, uses theme inheritance to set the font. This setting affects axis titles, legend titles, the plot title and tag text.

Value

A ggplot2 theme object (class theme).

Details

This theme takes ggplot2::theme_gray() and sets all colour and fill values to NULL, except for the top-level elements (line, rect, and title), which have colour = ink, and fill = paper. This leaves the spacing and non-color defaults of the default ggplot2 themes in place.

Unlike theme_foundation(), the other themes in this package (e.g. theme_economist(), theme_excel(), theme_hc()) intentionally replicate a fixed, published visual style, so they do not expose ink/paper/accent arguments.

Examples

library(ggplot2)

ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_foundation()


# Extend the foundation to build a new theme
theme_minimal_box <- function(...) {
  theme_foundation(...) +
    theme(
      panel.grid = element_blank(),
      axis.ticks = element_line()
    )
}

ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_minimal_box()