Skip to contents

Adapted from {mdthemes} function to provide option to render text as markdown within {ggplot2} theme

Usage

add_md(theme, all_plain = TRUE)

Arguments

theme

An object of class theme

all_plain

logical. Should all text be plain by default?

Value

An object of class theme that can be added to any ggplot

Examples

library(ggplot2)
data(mtcars)

# Create a custom theme
my_theme <- theme_gray() +
  theme(
    panel.grid.minor = element_blank(),
    panel.grid.major = element_blank()
  )
p <- ggplot(mtcars, aes(hp)) +
  geom_histogram() +
  ggtitle("Mixing **bold** and *italics* is easy")

# Text is not rendered
p + my_theme
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.


# Text is rendered properly
p + add_md(theme_emw)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.