Create perceptually continuous palettes of R colours.
marine.colours(
n, chroma = 0.65, luminance = c(0.35, 1),
alpha = 1, gamma = 1, fixup = TRUE
)
diverging.colours(
n, chroma = c(.1, .75), luminance = c(1, .35),
alpha = 1, gamma = 1, fixup = TRUE
)
A character vector of length n
containing colour specifications
for use with R graphics functions.
Number of colours to return.
Specifies the chroma (how saturated should the colours be) for the palette, a real number between \(0\) and \(1\). May also be a two-element vector, in which case the chroma is changed smoothly from start to finish of the resulting palette.
Specifies the luminance (how bright should the colours be) of the colours constituting the palette. Typically, a two-element vector of real numbers between \(0\) and \(1\) to indicate smooth change along the palette, but can also be a fixed number.
Specifies the transparency of the colours of the palette. As above,
can be a fixed number or a two-element vector in the range
\([0,1]\). Typically, fully opaque (alpha=1
) colours are
used.
Provides the power coefficient for the hue/chroma/luminance/alpha
growth formulae. May be useful when it is needed to sacrifice the
perceptual linearity of the palette to provide more contrast for
smaller or bigger values on the plot. The gamma-corrected values
are obtained by computing
\(x ^ \gamma\),
\(x \in [0;1]\), then scaling
the result linearly to the required range. Typically, linear growth
(gamma = 1
) is preferred.
Whether to correct the palette if the resulting colours happen to
fall outside the valid RGB range (passed as-is to hcl
).
Unrepresentable colours are returned as NA
s, but fixing the
palette may make it less perceptually uniform.
The marine.colours
palette is used by default by all
plot
methods (e.g. plot.feem
) for FEEM-like data
to show absolute values. It is designed to retain perceptual
uniformity even after complete desaturation.
The diverging.colours
palette is used by
plot.feem.resid
to display residual values. People with
severe colour vision deficiency (tritanopia or monochromacy) won't be
able to discern positive and negative branches of the palette, but
it's supposed to be legible for people with deuteranopia and
protanopia.
Insired by cmocean palette called “haline” (https://matplotlib.org/cmocean/#haline), but using R's implementation of polar CIE-LUV colour space instead of CAM02-UCS.
CUBEHELIX (https://people.phy.cam.ac.uk/dag9/CUBEHELIX/) is a similar technique using BT.601 luminance coefficients and RGB colour space.
plot.feem
, hcl
image(volcano, col = marine.colours(256))
Run the code above in your browser using DataLab