scale_cividis: cividis color scales

Description Usage Arguments Details Author(s) Examples

Description

Uses the cividis color scale.

Usage

1
2
3
4
5
6
7
8
scale_color_cividis(..., alpha = 1, begin = 0, end = 1, direction = 1,
  discrete = FALSE, option = "V")

scale_colour_cividis(..., alpha = 1, begin = 0, end = 1, direction = 1,
  discrete = FALSE, option = "V")

scale_fill_cividis(..., alpha = 1, begin = 0, end = 1, direction = 1,
  discrete = FALSE, option = "V")

Arguments

...

parameters to discrete_scale or scale_fill_gradientn

alpha

pass through parameter to cividis

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 as output by cividis_pal. If -1, the order of colors is reversed.

discrete

generate a discrete palette? (default: FALSE - generate continuous palette)

option

A character string indicating the colormap option to use. At the moment, only option "cividis" (or "V") is available.

Details

For discrete == FALSE (the default) all other arguments are as to scale_fill_gradientn or scale_color_gradientn. Otherwise the function will return a discrete_scale with the plot-computed number of colors.

See cividis for more information on the color scale.

Author(s)

Marco Sciaini msciain@uni-goettingen.de / @msciain, C?dric Scherer scherer@izw-berlin.de / @CedScherer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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_cividis(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_cividis() + theme_bw()


# ripped 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_cividis() + theme_bw()

library(ggplot2)
library(MASS)
library(gridExtra)

data("geyser", package="MASS")

ggplot(geyser, aes(x = duration, y = waiting)) +
  xlim(0.5, 6) + ylim(40, 110) +
  stat_density2d(aes(fill = ..level..), geom="polygon") +
  theme_bw() +
  theme(panel.grid=element_blank()) -> gg

grid.arrange(
  gg + scale_fill_cividis(option="V") + labs(x="Virdis V", y=NULL),
  ncol=2, nrow=2
)

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