Built-in complete themes in {ggplot2}
   get_help() docs


Description

All functions documented here are part of the {ggplot2} package, which is part of the {tidyverse}.

The {ggplot2} package provides several built-in complete themes for styling the overall look of your plot. The default theme used is theme_gray() (aka theme_grey()). You can specify a built-in theme in one of two ways:

Available complete themes include the following:

To use these function, you need to either first load the {ggplot2} library, or always use the function with ggplot2:: notation.

# Load the library
library(ggplot2)
# Or, load the full tidyverse:
library(tidyverse)

# Or, use :: notation, for example with theme_bw()
ggplot2::theme_bw() 

Examples

The examples below use the msleep dataset. Learn more about this dataset with get_help("msleep").

# Show the msleep dataset with head()
head(msleep)
## # A tibble: 6 × 11
##   name  genus vore  order conservation sleep_total sleep_rem sleep_cycle awake  brainwt  bodywt
##   <chr> <chr> <chr> <chr> <chr>              <dbl>     <dbl>       <dbl> <dbl>    <dbl>   <dbl>
## 1 Owl … Aotus omni  Prim… <NA>                17         1.8      NA       7    0.0155    0.48 
## 2 Moun… Aplo… herbi Rode… nt                  14.4       2.4      NA       9.6 NA         1.35 
## 3 Grea… Blar… omni  Sori… lc                  14.9       2.3       0.133   9.1  0.00029   0.019
## 4 Cow   Bos   herbi Arti… domesticated         4         0.7       0.667  20    0.423   600    
## 5 Thre… Brad… herbi Pilo… <NA>                14.4       2.2       0.767   9.6 NA         3.85 
## 6 Nort… Call… carni Carn… vu                   8.7       1.4       0.383  15.3 NA        20.5


# Set the default theme of all subsequent plots to theme_bw(), for example
# Don't forget parentheses!
theme_set(theme_bw())


theme_gray()

# Example of a plot using theme_gray (the default)
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  # Optional, since this is the default
  theme_gray()


theme_bw()

# Example of a plot using theme_bw()
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  theme_bw()


theme_linedraw()

# Example of a plot using theme_linedraw()
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  theme_linedraw()


theme_light()

# Example of a plot using theme_light()
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  theme_light()


theme_dark()

# Example of a plot using theme_dark()
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  theme_dark()


theme_minimal()

# Example of a plot using theme_minimal()
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  theme_minimal()


theme_classic()

# Example of a plot using theme_classic()
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  theme_classic()


theme_void()

# Example of a plot using theme_void()
# This theme is completely blank!
ggplot(msleep) + 
  aes(x = sleep_rem, y = awake) + 
  geom_point() +
  theme_void()