Viridis Color Schemes

Author

Andrew Grogan-Kaylor

Published

July 25, 2024

1 Introduction

The Viridis color palettes are designed to have a number of advantages.

  1. Aesthetically pleasing
  2. Perceptually uniform
  3. Color-blind friendly

More details can be found at https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html

2 A Basic Plot

Show the code
x <- seq(1,10)

mydata <- data.frame(x)

library(ggplot2)

p1 <- ggplot(mydata,
       aes(x = x, 
           fill = factor(x),
           y = 1)) + 
  geom_col() + 
  scale_x_continuous(breaks=seq(1,10,1)) +
  theme_minimal() +
  theme(axis.text.y = element_blank(),
        axis.ticks.y = element_blank(),
        axis.title.y = element_blank())

p1 # replay this plot

3 Palettes

3.1 Viridis

Show the code
p1 + 
  labs(title = "Viridis") +
  scale_fill_viridis_d(name = "viridis")

Show the code
ggsave("viridis.png")
Saving 7 x 3 in image

3.2 Cividis

Show the code
p1 + 
  labs(title = "Cividis") +
  scale_fill_viridis_d(name = "Cividis",
                       option = "cividis")

3.3 Plasma

Show the code
p1 + 
  labs(title = "Plasma") +
  scale_fill_viridis_d(name = "Plasma",
                       option = "plasma")

3.4 Magma

Show the code
p1 + 
  labs(title = "Magma") +
  scale_fill_viridis_d(name = "Magma",
                       option = "magma")

3.5 Mako

Show the code
p1 + 
  labs(title = "Magma") +
  scale_fill_viridis_d(name = "Mako",
                       option = "mako")

3.6 Rocket

Show the code
p1 + 
  labs(title = "Rocket") +
  scale_fill_viridis_d(name = "Rocket",
                       option = "rocket")

3.7 Turbo

Show the code
p1 + 
  labs(title = "Turbo") +
  scale_fill_viridis_d(name = "Turbo",
                       option = "turbo")