R - improved text rendering of ggplot2 plots with mdthemes package

30 May 2020

See also ggtext package !

mdthemes adds support for rendering text as markdown to your favorite ggplot2 themes thanks to the awesome ggtext package.

Currently, mdthemes contains all themes from ggplot2, ggthemes, hrbrthemes, tvthemes and cowplot with support for rendering text as markdown. All themes start with md_ followed by the name of the original theme, e.g. md_theme_bw().

library(ggplot2)
library(mdthemes)
data(mtcars)

p <- ggplot(mtcars, aes(hp, mpg)) +
  geom_point() +
  labs(
    title = "This is a **bold** title",
    subtitle = "And an *italics* subtitle",
    x = "**_hp_**",
    caption = "<span style = 'color:blue'>A blue caption</span>"
  )

p + theme_minimal()
p + md_theme_minimal()
[ R  function  visualization  plot  package  ggplot2  text  ]