theme_td_grid: Add the grid theme from dunnr to a ggplot

View source: R/themes.R

theme_td_gridR Documentation

Add the grid theme from dunnr to a ggplot

Description

This theme is just theme_bw() with some slight tweaks, like softer colors and Droid Serif as the default font.

Usage

theme_td_grid(
  base_size = 12,
  base_family = "Droid Serif",
  base_line_size = base_size/24
)

Arguments

base_size

base font size in pts.

base_family

base font family.

base_line_size

base size for line elements.

Value

The complete theme.

Examples

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

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

p <- penguins %>%
  filter(!is.na(flipper_length_mm)) %>%
  ggplot(aes(x = flipper_length_mm, y = species)) +
  geom_violin(aes(fill = species), show.legend = FALSE) +
  labs(x = "Flipper length (mm)", y = NULL) +
  facet_wrap(~year) +
  scale_fill_brewer(palette = "Set1") +
  scale_x_continuous(breaks = seq(180, 220, 20))

p + theme_td_grid()

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