marine.colours {albatross}R Documentation

Perceptually uniform palettes

Description

Create perceptually continuous palettes of R colours.

Usage

  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
  )

Arguments

n

Number of colours to return.

chroma

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.

luminance

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.

alpha

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.

gamma

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.

fixup

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 NAs, but fixing the palette may make it less perceptually uniform.

Details

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.

Value

A character vector of length n containing colour specifications for use with R graphics functions.

marinecolours.png

The marine.colours palette at the default values of C_{uv}^* = 0.65, L^* \in [0.35; 1], \alpha = \gamma = 1.

divergingcolours.png

The diverging.colours palette at the default values of C_{uv}^* \in [0.1; 0.75], L^* \in [0.35; 1], \alpha = \gamma = 1.

References

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://www.mrao.cam.ac.uk/~dag/CUBEHELIX/) is a similar technique using BT.601 luminance coefficients and RGB colour space.

See Also

plot.feem, hcl

Examples

  image(volcano, col = marine.colours(256))

[Package albatross version 0.3-7 Index]