Need help with ggdark?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

nsgrantham
128 Stars 8 Forks Other 24 Commits 0 Opened issues

Description

Dark mode for ggplot2 themes

Services available

!
?

Need anything else?

Contributors list

# 346,914
R
HTML
Shell
tidyver...
22 commits

ggdark

Travis-CI Build Status AppVeyor Build Status

Installation

You can install ggdark from CRAN with:

install.packages("ggdark")

If you want the development version, you can install ggdark from GitHub with:

# install.packages("devtools")
devtools::install_github("nsgrantham/ggdark")

Dark mode for ggplot2

library(ggplot2)

p

library(ggdark)

p + dark_theme_gray() # the dark version #> Inverted geom defaults of fill and color/colour. #> To change them back, use invert_geom_defaults().

# modify the theme to your liking, as you would in ggplot2
p + dark_theme_gray(base_family = "Fira Sans Condensed Light", base_size = 14) + 
  theme(plot.title = element_text(family = "Fira Sans Condensed"),
        plot.background = element_rect(fill = "grey10"),
        panel.background = element_blank(),
        panel.grid.major = element_line(color = "grey30", size = 0.2),
        panel.grid.minor = element_line(color = "grey30", size = 0.2),
        legend.background = element_blank(),
        axis.ticks = element_blank(),
        legend.key = element_blank(),
        legend.position = c(0.815, 0.27))

Dark themes

ggdark provides dark versions of all themes available in ggplot2:

mtcars2 
p + dark_theme_gray()

p + dark_theme_bw()

p + dark_theme_linedraw()

p + dark_theme_light()  # quite dark

p + dark_theme_dark()  # quite light

p + dark_theme_minimal()

p + dark_theme_classic()

p + dark_theme_void()

Make your own dark theme

Use

dark_mode
on any theme to create its dark version.
invert_geom_defaults()  # change geom defaults back to black

library(gapminder)

p

# install.packages("ggthemes")
library(ggthemes)

p + theme_fivethirtyeight()

p + dark_mode(theme_fivethirtyeight())
#> Inverted geom defaults of fill and color/colour.
#> To change them back, use invert_geom_defaults().

invert_geom_defaults()  # leave the geom defaults how you found them!

Happy plotting! 🖤

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.