Learn R Programming

ursa (version 3.10.4)

cubehelix: Generate "cubehelix" palette.

Description

cubehelix returns set of RGB colours, which are screen display of intensity images

Usage

cubehelix(n, value = numeric(), weak = NA, rich = NA, rotate = NA, hue = NA, gamma = 1,
          dark = NA, light = NA, bright = NA, inv = NA, verbose = NA)

Value

Vector of RGB color specification.

Arguments

n

Positive integer. Length of returned color vector. If n is missing and length of value is positive, then length of value. If missing n and empty value, then n=256.

value

Numeric vector of values, which are associated with a palette. If both positive and negative values are in this vector, then divergence color palette is returned. Default in numeric of length zero (unspecified).

weak

Numeric. The angle (in degrees) of the helix for color with light intensity. If both rich and weak are specified, the rotate is defined as difference between rich and weak. If all weak, rich and rotate are unspecified, then random values are used. Default is NA (unspecified).

rich

Numeric. The angle (in degrees) of the helix for color with dark intensity. If both rich and weak are specified, the rotate is defined as difference between rich and weak. If all weak, rich and rotate are unspecified, then random values are used. Default is NA (unspecified).

rotate

Numeric. The angle of rotation (in degrees) of the helix over the scale; can be negative. If rotate and weak are specified, then rich is defined as sum of weak and rotate. If rotate and rich are specified, then weak is defined as difference between rotate and weak. If all weak, rich and rotate are unspecified, then random values are used. Default is NA (unspecified).

hue

Non-negative numeric. Saturation of color. hue=0 gives pure greyscale. If unspecified, then random value in interval [0.9, 1.5] is used. Default is NA (unspecified).

gamma

Numeric. Power of intensity. Intensity is between dark and light, which are normalized to interval [0, 1]. gamma changes normalized intensity to intensity^gamma. Default is 1.

dark

Positive numeric in interval between 0 and 255. The intensity of the darkest color in the palette. For light backgrounds default is 63. For dark backgrounds default is 14 (inverse order with light).

light

Positive numeric in interval between 0 and 255. The intensity of the lightest color in the palette. For light backgrounds default is 241, for dark backgrounds default is 192 (inverse order with dark).

bright

Positive numeric in interval between 0 and 255. Value for equal intensity for dark and light in the palette. Applied only for both dark=NA and light=NA.

inv

Logical. Inversion of color intensity. If TRUE then color vector is reversed before return. Default is FALSE.

verbose

Logical. Value TRUE provides information about cube helix on console. Default is NA, which is interpreted as FALSE.

Author

Dave Green

Robin Evans

Nikita Platonov platonov@sevin.ru

Acknowledgements

Dave Green, Robin Evans

Details

This is modified source code of function cubeHelix() from package rje under GPL>=2 license.

The palette design is oriented that figures can be printed on white paper. Under this assumption, light color is for small values, and dark color is for big values. In some computer vision and GIS software black background is used, and in this case light color for big values, and dark color of small values looks more naturally. For some thematic maps big values are light, and small values are small (for example, sea ice concentration: open water is blue, close ice is white). RGB and Grayscale remote sensing and photo imagery use light colors for strong signal, and dark colors for weak signal.

Light background is default for figure (specified by argument background in function compose_open).

The palette divergency can be defined only if value is specified. If all values are positive, or all values are negative, then returned palette is not drivergent. For divergent palettes the helix sequence is continuous.

If dark and lihgt are unspecified, the color contrast bewteen dark and light drops on reducing number of colors in returned vector.

References

Dave Green's `cubehelix' colour scheme.

Green, D. A., 2011, `A colour scheme for the display of astronomical intensity images', Bulletin of the Astronomical Society of India, 39, 289. http://astron-soc.in/bulletin/11June/289392011.pdf (pre-print at 'arxiv.org')

rje::cubeHelix(); rje at CRAN: https://CRAN.R-project.org/package=rje

Examples

Run this code
session_grid(NULL)
set.seed(352)
session_grid(regrid(mul=1/16))
a <- ursa_dummy(3,min=0,max=255)
b4 <- b3 <- b2 <- b1 <- vector("list",length(a))
for (i in seq_along(b1)) {
   b1[[i]] <- colorize(a[i],pal=cubehelix(11,weak=45*i,rotate=+270),ncolor=11)
   b2[[i]] <- colorize(a[i],pal=cubehelix(11,weak=45*i,rotate=-270),ncolor=11)
   b3[[i]] <- colorize(a[i]-127,pal=cubehelix)
   hue <- sample(seq(2)-1,1)
   s <- ifelse(hue==0,NA,runif(1,min=91,max=223))
   b4[[i]] <- colorize(a[i]-127,pal=cubehelix,pal.hue=hue,pal.dark=s,pal.light=s)
}
display(c(b1,b2),layout=c(2,NA),decor=FALSE)
display(c(b3,b4),layout=c(2,NA),decor=FALSE)

Run the code above in your browser using DataLab