viridis

0th

Percentile

Matplotlib 'viridis' color map

This function creates a vector of n equally spaced colors along the Matplolib 'viridis' color map created by https://github.com/stefanv{Stéfan van der Walt} and https://github.com/njsmith{Nathaniel Smith}. This color map is designed in such a way that it will analytically be perfectly perceptually-uniform, both in regular form and also when converted to black-and-white. It is also designed to be perceived by readers with the most common form of color blindness.

Usage
viridis(n, alpha = 1)

viridisMap(n = 256, alpha = 1)

Arguments
n
The number of colors ($\ge 1$) to be in the palette.
alpha
The alpha transparency, a number in [0,1], see argument alpha in hsv.
Details

Semi-transparent colors ($0 < alpha < 1$) are supported only on some devices: see rgb.

Value

  • viridis returns a character vector, cv, of color hex codes. This can be used either to create a user-defined color palette for subsequent graphics by palette(cv), a col = specification in graphics functions or in par.

    viridisMap returns a n lines data frame containing the red (R), green (G), blue (B) and alpha (alpha) channels of n equally spaced colors along the 'viridis' color map. n = 256 by default, which corresponds to the data from the original 'viridis' color map in Matplotlib.

Aliases
  • viridis
  • viridisMap
Examples
library(ggplot2)
library(hexbin)

dat <- within(data.frame(x = rnorm(10000), y = rnorm(10000)), {
  Distance <- sqrt(x^2 + y^2)
})

ggplot(dat, aes(x = x, y = y)) +
  geom_hex() + coord_fixed() +
  scale_fill_gradientn(colours = viridis(256))
Documentation reproduced from package viridis, version 0.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.