theme_schneidr: A simple, reader-friendly ggplot2 theme

Description Usage Arguments Value Examples

View source: R/theme_schneidr.R

Description

A simple ggplot2 theme that tries to simplify the reader's experience by reducing unnecessary lines, and aligning text to be immediately readable. Readers shouldn't have to tilt their heads to read axis labels, and the titles should be the first thing they read.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
theme_schneidr(
  base_size = 8,
  base_font_family = "Rubik",
  titles_font_family = "Libre Franklin",
  grid_lines = FALSE,
  axis_lines = TRUE,
  axis_ticks = TRUE,
  x_axis_text_align = "center",
  y_axis_text_align = "center",
  markdown_elements = "none"
)

Arguments

base_size

A single number giving the base size of text in the plot.

base_font_family

Name of a font family to be used in all text outside of overall plot titles.

titles_font_family

Name of a font family to be used in overall plot titles.

grid_lines

A single value from 'x', 'y', 'TRUE', or 'FALSE', specifying which dimensions of gridlines should be included.

axis_lines

A single value from 'x', 'y', 'TRUE', or 'FALSE', specifying which axes should be marked with a line.

axis_ticks

A single value from 'x', 'y', 'TRUE', or 'FALSE', specifying which axes should have tick marks on breaks.

x_axis_text_align

A single value from 'left', 'center', or 'right', indicating how x axis labels should be aligned.

y_axis_text_align

A single value from 'left', 'center', or 'right', indicating how y axis labels should be aligned.

markdown_elements

Specify which plot elements should be created using ‘ggtext::element_markdown()', allowing the use of markdown text including CSS and HTML. Can be ither ’none' or a character vector with one or more of the following: 'title', 'subtitle', 'caption', 'axis title', 'axis label', or 'strip'.

Value

A full theme element.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(ggplot2)
mtcars[['gear']] <- factor(mtcars[['gear']])
mtcars_plot <- ggplot(mtcars) +
geom_point(aes(x = wt, y = mpg, color = gear)) +
labs(title = "Fuel economy and weight",
     subtitle = "Data from the 1974 Motor Trend US magazine.",
     x = "Weight (1000 lbs)",
     y = "Fuel economy (mpg)")

# Basic theme example
  mtcars_plot +
    theme_schneidr(grid_lines = TRUE, axis_lines = FALSE)

# Using markdown elements

 mtcars_plot +
   labs(title = "Fuel economy and weight",
        subtitle = "Data from the 1974 Motor Trend US magazine.",
        x = "**Weight**<br>*1000 lbs*",
        y = "**Fuel economy**<br>*mpg*")
   theme_schneidr(grid_lines = TRUE, axis_lines = FALSE,
                  markdown_elements = 'axis title')

bschneidr/schneidr documentation built on Dec. 25, 2021, 4:55 p.m.