rainbow_hcl {colorspace} | R Documentation |
Color palettes based on the HCL and HSV color spaces.
rainbow_hcl(n, c = 50, l = 70, start = 0, end = 360*(n-1)/n, gamma = NULL, fixup = TRUE, ...) sequential_hcl(n, h = 260, c. = c(80, 0), l = c(30, 90), power = 1.5, gamma = NULL, fixup = TRUE, ...) heat_hcl(n, h = c(0, 90), c. = c(100, 30), l = c(50, 90), power = c(1/5, 1), gamma = NULL, fixup = TRUE, ...) terrain_hcl(n, h = c(130, 0), c. = c(80, 0), l = c(60, 95), power = c(1/10, 1), gamma = NULL, fixup = TRUE, ...) diverge_hcl(n, h = c(260, 0), c = 80, l = c(30, 90), power = 1.5, gamma = NULL, fixup = TRUE, ...) diverge_hsv(n, h = c(240, 0), s = 1, v = 1, power = 1, gamma = NULL, fixup = TRUE, ...)
n |
the number of colors (>= 1) to be in the palette. |
c, c. |
chroma value in the HCL color description. |
l |
luminance value in the HCL color description. |
start |
the hue at which the rainbow begins. |
end |
the hue at which the rainbow ends. |
h |
hue value in the HCL or HSV color description, has to be in [0, 360] for HCL and in [0, 1] for HSV colors. |
s |
saturation value in the HSV color description. |
v |
value value in the HSV color description. |
power |
control parameter determining how chroma and luminance should be increased (1 = linear, 2 = quadratic, etc.). |
gamma |
Deprecated. |
fixup |
logical. Should the color be corrected to a valid RGB value before correction? |
... |
Other arguments passed to |
All functions compute palettes based on either the HCL (polarLUV
)
or the HSV (HSV
) color space.
rainbow_hcl
computes a rainbow of colors (qualitative palette)
defined by different hues given a single value of each chroma and luminance.
It corresponds to rainbow
which computes a rainbow in
HSV space.
sequential_hcl
gives a sequential palette starting at the full
color HCL(h
, c[1]
, l[1]
) through to a light color
HCL(h
, c[2]
, l[2]
) by interpolation.
diverge_hcl
and diverge_hsv
, compute
a set of colors diverging from a neutral center (gray or white, without
color) to two different extreme colors (blue and red by default). This
is similar to cm.colors
. For the diverging HSV colors,
two hues h
are needed, a maximal saturation s
and a
fixed value v
. The saturation is then varied to obtain the
diverging colors. For the diverging HCL colors, again two hues h
are needed, a maximal chroma c
and two luminances l
.
The colors are then created by an interpolation between the
full color HCL(h[1]
, c
, l[1]
), a neutral color HCL(h
, 0, l[2]
)
and the other full color HCL(h[2]
, c
, l[1]
).
The palette heat_hcl
gives an implementation of heat.colors
in HCL space. By default, it goes from a red to a yellow hue, while
simultaneously going to lighter colors (i.e., increasing luminance)
and reducing the amount of color (i.e., decreasing chroma).
The terrain_hcl
palette simply calls heat_hcl
with different
parameters, providing colors similar in spirit to terrain.colors
.
The lighter colors are not strictly HCL colors, though.
A character vector with (s)RGB codings of the colors in the palette.
Achim Zeileis Achim.Zeileis@R-project.org
Zeileis A., Hornik K. and Murrell P. (2009), Escaping RGBland: Selecting Colors for Statistical Graphics. Computational Statistics & Data Analysis, 53, 3259-3270. doi:10.1016/j.csda.2008.11.033 Preprint available from http://statmath.wu-wien.ac.at/~zeileis/papers/Zeileis+Hornik+Murrell-2009.pdf.
## convenience demo functions wheel <- function(col, radius = 1, ...) pie(rep(1, length(col)), col = col, radius = radius, ...) pal <- function(col, border = "light gray") { n <- length(col) plot(0, 0, type="n", xlim = c(0, 1), ylim = c(0, 1), axes = FALSE, xlab = "", ylab = "") rect(0:(n-1)/n, 0, 1:n/n, 1, col = col, border = border) } ## qualitative palette wheel(rainbow_hcl(12)) ## a few useful diverging HCL palettes par(mar = rep(0, 4), mfrow = c(4, 1)) pal(diverge_hcl(7)) pal(diverge_hcl(7, h = c(246, 40), c = 96, l = c(65, 90))) pal(diverge_hcl(7, h = c(130, 43), c = 100, l = c(70, 90))) pal(diverge_hcl(7, h = c(180, 70), c = 70, l = c(90, 95))) pal(diverge_hcl(7, h = c(180, 330), c = 59, l = c(75, 95))) pal(diverge_hcl(7, h = c(128, 330), c = 98, l = c(65, 90))) pal(diverge_hcl(7, h = c(255, 330), l = c(40, 90))) pal(diverge_hcl(7, c = 100, l = c(50, 90), power = 1)) ## sequential palettes pal(sequential_hcl(12)) pal(heat_hcl(12, h = c(0, -100), l = c(75, 40), c = c(40, 80), power = 1)) pal(terrain_hcl(12, c = c(65, 0), l = c(45, 95), power = c(1/3, 1.5))) pal(heat_hcl(12, c = c(80, 30), l = c(30, 90), power = c(1/5, 1.5))) ## compare base and colorspace palettes ## (in color and desaturated) par(mar = rep(0, 4), mfrow = c(2, 2)) ## rainbow color wheel wheel(rainbow_hcl(12)) wheel(rainbow(12)) wheel(desaturate(rainbow_hcl(12))) wheel(desaturate(rainbow(12))) ## diverging red-blue colors pal(diverge_hsv(7)) pal(diverge_hcl(7, c = 100, l = c(50, 90))) pal(desaturate(diverge_hsv(7))) pal(desaturate(diverge_hcl(7, c = 100, l = c(50, 90)))) ## diverging cyan-magenta colors pal(cm.colors(7)) pal(diverge_hcl(7, h = c(180, 330), c = 59, l = c(75, 95))) pal(desaturate(cm.colors(7))) pal(desaturate(diverge_hcl(7, h = c(180, 330), c = 59, l = c(75, 95)))) ## heat colors pal(heat.colors(12)) pal(heat_hcl(12)) pal(desaturate(heat.colors(12))) pal(desaturate(heat_hcl(12))) ## terrain colors pal(terrain.colors(12)) pal(terrain_hcl(12)) pal(desaturate(terrain.colors(12))) pal(desaturate(terrain_hcl(12)))