cube_helix: Sequential color palette using the cube helix system

Description Usage Arguments Value Examples

View source: R/cube_helix.r

Description

Creates a perceptually monotonously decreasing (or increasing) lightness color palette with different tones. This was necessary in pre-viridis times, by now you can probably just use hcl.colors

Usage

 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
39
40
41
42
43
44
45
46
47
48
49
cube_helix(
  n = 6,
  start = 0,
  r = 0.4,
  hue = 0.8,
  gamma = 1,
  light = 0.85,
  dark = 0.15,
  reverse = FALSE
)

scale_colour_cube_helix(
  ...,
  start = 0,
  r = 0.4,
  hue = 0.8,
  gamma = 1,
  light = 0.85,
  dark = 0.15,
  reverse = FALSE,
  discrete = TRUE,
  guide = if (discrete) "legend" else "colourbar"
)

scale_color_cube_helix(
  ...,
  start = 0,
  r = 0.4,
  hue = 0.8,
  gamma = 1,
  light = 0.85,
  dark = 0.15,
  reverse = FALSE,
  discrete = TRUE,
  guide = if (discrete) "legend" else "colourbar"
)

scale_fill_cube_helix(
  ...,
  start = 0,
  r = 0.4,
  hue = 0.8,
  gamma = 1,
  light = 0.85,
  dark = 0.15,
  reverse = FALSE,
  discrete = TRUE,
  guide = if (discrete) "legend" else "colourbar"
)

Arguments

n

Number of colors to return (default: 6)

start

Hue to start helix at (\textrm{start} \in [0,3], default: 0)

r

Number of rotations of the helix. Can be negative. (default: 0.4)

hue

Saturation. 0 means greyscale, 1 fully saturated colors (default: 0.8)

gamma

Emphasize darker (gamma < 1) or lighter (gamma > 1) colors (default: 1)

light

Lightest lightness (default: 0.85)

dark

Darkest lightness (default: 0.15)

reverse

logical. If TRUE, reverse lightness (default: FALSE)

...

parameters passed to discrete_scale or continuous_scale

discrete

If TRUE, return a discrete scale, if FALSE a continuous one (default: TRUE)

guide

Type of scale guide to use. See guides

Value

A character vector of hex colors with length n

Examples

1
2
3
4
5
6
palette(cube_helix())
image(matrix(1:6), col = 1:6, pch = 19, axes = FALSE)

cr <- scales::colour_ramp(cube_helix(12, r = 3))
r <- runif(100)
plot(1:100, r, col = cr(r), type = 'b', pch = 20)

destiny documentation built on Nov. 8, 2020, 7:38 p.m.

Related to cube_helix in destiny...