Tidyverse
ggplot2.tidyverse.org › reference › scale_viridis.html
Viridis colour scales from viridisLite — scale_colour_viridis_d • ggplot2
# viridis is the default colour/fill scale for ordered factors set.seed(596) dsamp <- diamonds[sample(nrow(diamonds), 1000), ] ggplot(dsamp, aes(carat, price)) + geom_point(aes(colour = clarity)) # Use viridis_d with discrete data txsamp <- subset(txhousing, city %in% c("Houston", "Fort Worth", "San Antonio", "Dallas", "Austin")) (d <- ggplot(data = txsamp, aes(x = sales, y = median)) + geom_point(aes(colour = city))) d + scale_colour_viridis_d() # Change scale label d + scale_colour_viridis_d("City\nCenter") # Select palette to use, see ?scales::pal_viridis for more details d + scale_colour_v
Sjmgarnier
sjmgarnier.github.io › viridis › reference › scale_viridis.html
Viridis Color Scales for ggplot2 — scale_fill_viridis • viridis
library(ggplot2) # Ripped from the pages of ggplot2 p <- ggplot(mtcars, aes(wt, mpg)) p + geom_point(size = 4, aes(colour = factor(cyl))) + scale_color_viridis(discrete = TRUE) + theme_bw() # Ripped from the pages of ggplot2 dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6) dsub$diff <- with(dsub, sqrt(abs(x - y)) * sign(x - y)) d <- ggplot(dsub, aes(x, y, colour = diff)) + geom_point() d + scale_color_viridis() + theme_bw() # From the main viridis example dat <- data.frame(x = rnorm(10000), y = rnorm(10000)) ggplot(dat, aes(x = x, y = y)) + geom_hex() + coord_fixed() + scale_fill_viridi
r - Modify viridis palette in ggplot - Stack Overflow
What I would like to do is to special-case the (0,1] value and color that in red but to retain the viridis gradient for the remaining values. I know I could change the color on the fly but I wonder if it's also possible to construct a new discrete color palette that has red as its first color ... More on stackoverflow.com
Something about the popular viridis palette
I write a small Substack about adaptive software, and my latest piece is about data visualization · By adaptive software I mean software that keeps adapting to users and changing after it ships More on reddit.com
What's your favorite color palette for scRNA-seq feature plots?
I love the magma palette. CorkO is kind of hard to see. I usually dont like when a bright color represents an intermediate value. More on reddit.com
Need help picking color palette for figures
Hello all! I'm not sure if this is quite the right sub (I can go elsewhere if not!) but I am defending my dissertation in a few weeks and I need help… More on reddit.com
CRAN
cran.r-project.org › web › packages › viridis › vignettes › intro-to-viridis.html
Introduction to the viridis color maps
It is immediately clear that the “rainbow” palette is not perceptually uniform; there are several “kinks” where the apparent color changes quickly over a short range of values. This is also true, though less so, for the “heat” colors. The other scales are more perceptually uniform, but “viridis...
RPubs
rpubs.com › mjvoss › psc_viridis
RPubs - Viridis Color Palette
August 10, 2021 - Viridis Color Palette · by Matthew Voss · Last updated about 5 years ago · Hide Comments (–) Share Hide Toolbars ·
Rdrr.io
rdrr.io › cran › viridis › man › viridis_pal.html
viridis_pal: Viridis Color Palettes in viridis: Colorblind-Friendly Color Maps for R
May 29, 2024 - A wrapper function around viridis to turn it into a palette function compatible with discrete_scale. viridis_pal(alpha = 1, begin = 0, end = 1, direction = 1, option = "D") See viridis and viridis.map for more information on the color palettes.
Databrewer
databrewer.co › R › visualization › 16-ggplot2-color-viridis-palette
A Complete Guide on the Viridis Color Palettes
José María Sallan Leyes at Universitat Politècnica de Catalunya. viridis_names <-c( "A (magma)", "B (inferno)", "C (plasma)", "D (viridis)", "E (cividis)", "F (rocket)", "G (mako)", "H (turbo)") n <- 50 # control the smoothness of color transitionpar(mfrow=c(4,2), mar = rep(1, 4)) f <- ...
DevGenius
blog.devgenius.io › the-art-of-color-schemes-in-r-base-and-viridis-palettes-141f2b613541
The Art of Color Schemes in R: base and viridis palettes | by Dima from Mithridata | Dev Genius
June 6, 2023 - Here the scale_color_viridis() function is used to apply the Viridis color scale to the points in the scatter plot. The discrete = TRUE argument is used because the 'Species' variable is categorical. You probably wonder how it looks like when it is off. If you do, than we have to switch color to continuous variable, e.g.
CRAN
cran.r-project.org › web › packages › viridis › viridis.pdf pdf
viridis.pdf - CRAN
A character string indicating the color map option to use. Eight options are ... A data set containing the 2009 unemployment data in the USA by county. ... A wrapper function around viridis to turn it into a palette function compatible with discrete_scale.
Gotellilab
gotellilab.github.io › GotelliLabMeetingHacks › NickGotelli › ViridisColorPalette.html
Viridis color palette
September 6, 2018 - p4 + scale_fill_viridis_c(option="cividis") # "E" option · When working with discrete color scales, use the scale_fill_viridis_d() function.
The Data School
thedataschool.co.uk › gwilym-lockwood › viridis-colours-tableau
Viridis colours in Tableau
Discover the power of data analytics with The Data School. As the training arm of The Information Lab, we equip organizations worldwide with the tools and knowledge to harness the true value of their data
R-universe
cran.r-universe.dev › viridis › doc › manual.html
Package 'viridis' reference manual
A wrapper function around viridis to turn it into a palette function compatible with discrete_scale. viridis_pal(alpha = 1, begin = 0, end = 1, direction = 1, option = "D") viridis_pal(alpha = 1, begin = 0, end = 1, direction = 1, option = "D") See viridis and viridis.map for more information on the color palettes.
Top answer 1 of 2
5
This is basically the same as @seasmith's answer, except with the addition of saving the palette to a variable to use later. I do this often for explicitly setting a NA color and then using the palette across multiple plots.
Other packages have similar functions to the viridis ones: for example, you can get ColorBrewer palettes from RColorBrewer::brewer.pal, CartoColor palettes from rcartocolor::carto_pal, or any of the ggthemes ones from functions with the same name as the palette.
library(tidyverse)
plasma_pal <- c("red", viridis::plasma(n = 6))
plasma_pal
#> [1] "red" "#0D0887FF" "#6A00A8FF" "#B12A90FF" "#E16462FF" "#FCA636FF"
#> [7] "#F0F921FF"
iris %>%
ggplot(aes(Sepal.Length, Sepal.Width, color = cut(Petal.Length, 0:7))) +
geom_point() +
scale_color_manual(values = plasma_pal)

Created on 2018-04-19 by the reprex package (v0.2.0).
2 of 2
3
Requires a call to scale_color_manual()
iris %>%
ggplot(aes(Sepal.Length, Sepal.Width, color = cut(Petal.Length, 0:7))) +
geom_point() +
scale_color_manual(values = c("red", viridis::viridis(6)))

Sjmgarnier
sjmgarnier.github.io › viridisLite › reference › viridis.html
Viridis Color Palettes — viridis • viridisLite
... library(ggplot2) library(hexbin) ... the palette n = 200 image( 1:n, 1, as.matrix(1:n), col = viridis(n, option = "D"), xlab = "viridis n", ylab = "", xaxt = "n", yaxt = "n", bty = "n" )...
Sjmgarnier
sjmgarnier.github.io › viridis › reference › viridis_pal.html
Viridis Color Palettes — viridis_pal • viridis
A wrapper function around viridis to turn it into a palette function compatible with discrete_scale. viridis_pal(alpha = 1, begin = 0, end = 1, direction = 1, option = "D") ... The alpha transparency, a number in [0,1], see argument alpha in hsv.
R-bloggers
r-bloggers.com › r bloggers › [ggplot2] welcome viridis !
[ggplot2] Welcome viridis ! | R-bloggers
July 11, 2018 - To do that, the solution found by the viridis colormap is to avoid the red and to go from blue to yellow,as these colors can be seen by most of the colorblind. Let’s use the {dichromat} package to simulate that : ... As you can see, the contrast stays readable in every situation. Finally, to suit the printing need, the palette had to go from dark to light. And the wider range was from dark blue to bright yellow. Let’s just compare two examples:
RDocumentation
rdocumentation.org › packages › viridis › versions › 0.6.1 › topics › scale_fill_viridis
scale_fill_viridis function - RDocumentation
March 11, 2016 - (default: FALSE - generate continuous palette). ... A character string indicating the color map option to use. Eight options are available: ... # NOT RUN { library(ggplot2) # Ripped from the pages of ggplot2 p <- ggplot(mtcars, aes(wt, mpg)) p + geom_point(size = 4, aes(colour = factor(cyl))) + scale_color_viridis(discrete = TRUE) + theme_bw() # Ripped from the pages of ggplot2 dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6) dsub$diff <- with(dsub, sqrt(abs(x - y)) * sign(x - y)) d <- ggplot(dsub, aes(x, y, colour = diff)) + geom_point() d + scale_color_viridis() + theme_bw() # From th