colorpanel: Generates a set of colors that varies smoothly.

colorpanelR Documentation

Generates a set of colors that varies smoothly.

Description

(copied from the colorpanel man page from the gplots package. See NOTES below)

Usage

colorpanel(n, low, mid, high)

Arguments

n

Desired number of color elements in the panel

low

Color to use for the lowest value

mid

Color to use for the middle value. It may be ommited

high

Color to use for the highest value

Details

The values for ‘low, mid, high’ can be given as color names (‘red’), plot color index (2=red), and HTML-style RGB, (“\#FF0000”=red).

If ‘mid’ is supplied, then the returned color panel will consist of ‘n - floor(n/2)’ HTML-style RGB elements which vary smoothly between ‘low’ and ‘mid’, then between ‘mid’ and ‘high’. Note that if ‘n’ is even, the color ‘mid’ will occur twice at the center of the sequence.

If ‘mid’ is omitted, the color panel will vary smoothly beween ‘low’ and ‘high’.

Value

Vector of HTML-style RGB colors.

Note

The colorpanel function is copied from the gplots package (written by Warnes et al.) under the GPL-2 license. The gplots require heavy dependencies that prevent this function being used in speed-sensitive scenarios, e.g. in command-line tools.

Author(s)

Originally by Gregory R. Warnes <greg@warnes.net>. Adapted by Jitao David Zhang <jitao_david.zhang@roche.com>.

References

See gplots package.

See Also

blackyellow and royalbluered for two- and three-color panels.

Examples


showpanel <- function(col) {
  image(z=matrix(1:100, ncol=1), col=col, xaxt="n", yaxt="n")
}
 
par(mfrow=c(3,3))
 
# two colors only:
showpanel(colorpanel(8,low="red",high="green"))
 
# three colors
showpanel(colorpanel(8,"red","black","green"))
# note the duplicatation of black at the center, using an odd
# number of elements resolves this:
showpanel(colorpanel(9,"red","black","green"))
 
showpanel(greenred(64))
showpanel(redgreen(64))
showpanel(bluered(64))
showpanel(redblue(64))

showpanel(royalbluered(64))
showpanel(royalredblue(64))


bedapub/ribiosPlot documentation built on Sept. 1, 2023, 6:50 p.m.