cividis: 'cividis' color map

Description Usage Arguments Value Examples

Description

This function creates a vector of n equally spaced colors along the cividis color map created by Jamie R. Nuez and Sean M. Colby. This so-called "cividis" colormap is generated by optimizing the ["viridis" colormap](https://bids.github.io/colormap/) and is optimal for viewing by those with or without color vision deficiency (CVD), a different visual perception of colors that affects 8.5 [Python module called "cmaputil"](https://github.com/pnnl/cmaputil). Thus, it is designed to be perfectly perceptually-uniform, both in regular form and also when converted to black-and-white, and can be perceived by readers with all forms of color blindness.

Usage

1
2
3
4
cividis(n, alpha = 1, begin = 0, end = 1, direction = 1, option = "V")

cividisMap(n = 256, alpha = 1, begin = 0, end = 1, direction = 1,
  option = "V")

Arguments

n

The number of colors (≥ 1) to be in the palette.

alpha

The alpha transparency, a number in [0,1], see argument alpha in hsv.

begin

The (corrected) hue in [0,1] at which the cividis colormap begins.

end

The (corrected) hue in [0,1] at which the cividis colormap ends.

direction

Sets the order of colors in the scale. If 1, the default, colors are ordered from darkest to lightest. If -1, the order of colors is reversed.

option

A character string indicating the colormap option to use. So far, there is only one option called "cividis" (or "V").

Value

cividis 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.

cividisMap 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 'cividis' color map. n = 256 by default, which corresponds to the data from the original 'cividis' color map in Matplotlib.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(ggplot2)
library(hexbin)

dat <- data.frame(x = rnorm(10000), y = rnorm(10000))

ggplot(dat, aes(x = x, y = y)) +
  geom_hex() + coord_fixed() +
  scale_fill_gradientn(colours = cividis(256))

# using code from RColorBrewer to demo the palette
n = 200
image(
  1:n, 1, as.matrix(1:n),
  col = cividis(n = n, begin = 0, end = 1),
  xlab = "cividis n", ylab = "", xaxt = "n", yaxt = "n", bty = "n"
)

marcosci/cividis documentation built on May 27, 2019, 1:08 p.m.