Enhance Your Plots with ggthemes


The ggthemes package in R is an extension of ggplot2, offering a collection of additional themes and scales for ggplot2 charts.
This post showcases the key features of ggthemes and provides a set of graph examples using the package.

Documentation

{ggthemes}

Quick start


The ggthemes package in R extends ggplot2 by providing additional themes and scales inspired by various sources, including popular data visualization styles and software.

It offers a set of pre-built themes that can be easily applied to ggplot2 charts to quickly change their appearance.

✍️ author β†’ Jeffrey Arnold

πŸ“˜ documentation β†’ github

⭐️ more than 1000 stars on github

Installation


To get started with ggthemes, you can install it directly from CRAN using the install.packages function:

install.packages("ggthemes")

Basic usage


The ggthemes package allows you to apply pre-built themes to your ggplot2 charts using the theme_*() functions.

Here’s a basic example:

library(ggplot2)
library(ggthemes)

p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species, shape = Species)) +
  geom_point(size = 4) +
  labs(
    title = "Sepal Length vs Sepal Width by Species",
    x = "Sepal Length (cm)",
    y = "Sepal Width (cm)",
    caption = "Data source: Iris dataset"
  )

p + theme_economist()

Key features


ggthemes provides a wide range of pre-built themes inspired by various sources.

It includes a comprehensive set of theme_*() functions that can transform the overall appearance of a chart, as well as several additional functions such as:

This allows for easy and seamless integration of theme, color, and shape in any chart.

The following examples will demonstrate excellent combinations of these functions and their visual impact!


β†’ Theme 538 + color 538

p + theme_fivethirtyeight() + scale_color_fivethirtyeight()


β†’ Theme economist

p + theme_economist()


β†’ Theme excel + color excel

p + theme_excel() + scale_color_excel()


β†’ Theme calc + color calc + shape calc

p + theme_calc() + scale_color_calc() + scale_shape_calc()


β†’ Theme igray

p + theme_igray()


β†’ Theme few

p + theme_few()


β†’ Theme solarized + color solarized

p + theme_solarized() + scale_color_solarized()


β†’ Theme solarized (dark) + color solarized

p + theme_solarized(light = FALSE) + scale_color_solarized()


β†’ Theme tufte

p + theme_tufte()


β†’ Theme theme_wsj

p + theme_wsj()


β†’ Theme theme_stata + color stata + shape stata

p + theme_stata() + scale_color_stata() + scale_shape_stata()





❀️ 10 best R tricks ❀️

πŸ‘‹ After crafting hundreds of R charts over 12 years, I've distilled my top 10 tips and tricks. Receive them via email! One insight per day for the next 10 days! πŸ”₯