Learn R Programming

albatross (version 0.1-1)

marine.colours: Marine colours

Description

Create a perceptually contigous palette of R "#RRGGBB" colours, using hues typically associated with natural waters.

Usage

marine.colours(
  n, chroma = 0.65, luminance = c(0.35, 1),
  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 linearly 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 linear change along the palette, but can also be a fixed number. See the gamma argument if you want to make the change non-linear.

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 luminance growth formula. May be useful when it is needed to sacrifice the perceptual linearity of the palette to provide more constrast for darker or brighter areas of the plot. The exact expression used is luminance ^ gamma. 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.

Value

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

References

Insired by cmocean palette called “haline”, but using R's implementation of polar CIE-LUV colour space instead of CAM02-UCS.

See Also

hcl for the colour space used, CUBEHELIX for a similar technique using BT.601 luminance coefficients and RGB colour space.

Examples

Run this code
# NOT RUN {
  image(volcano, col = marine.colours(256))
# }

Run the code above in your browser using DataLab