theme_td_grey: Add the grey theme from dunnr to a ggplot

View source: R/themes.R

theme_td_greyR Documentation

Add the grey theme from dunnr to a ggplot

Description

This is a low contrast theme with a grey background that emphasizes title and facet text. The default font is Inter.

Usage

theme_td_grey(
  base_size = 12,
  base_family = "Inter",
  base_line_size = base_size/24,
  base_grey = "grey92",
  gridlines = "none"
)

Arguments

base_size

base font size in pts.

base_family

base font family.

base_line_size

base size for line elements.

base_grey

the specific grey to use throughout, default "grey92".

gridlines

Specifies the axes upon which to draw white gridlines: "xy", "x", "y", or "none" (default).

Value

The complete theme.

Examples

library(ggplot2)
library(palmerpenguins)
library(dplyr)

# Load the default font (Inter)
extrafont::loadfonts(quiet = TRUE)

p <- penguins %>%
  filter(!is.na(bill_length_mm)) %>%
  ggplot(aes(x = bill_length_mm, y = bill_depth_mm, color = species)) +
  geom_point(aes(shape = species), size = 3, alpha = 0.7) +
  geom_smooth(method = "lm", formula = "y ~ x", se = FALSE) +
  scale_color_brewer(palette = "Set1") +
  labs(
    title = "Penguin bill dimensions",
    subtitle = "Bill length and depth for different penguin species",
    x = "Bill length (mm)", y = "Bill depth (mm)",
    color = "Penguin species", shape = "Penguin species",
    caption = "Data from the palmerpenguins package"
  ) +
  facet_wrap(~species, nrow = 1)

p + theme_td_grey()

taylordunn/dunnr documentation built on Aug. 8, 2022, 12:28 p.m.