Learn R Programming

gplots (version 2.7.4)

rich.colors: Rich color palettes

Description

Create a vector of n colors that are perceptually equidistant and in an order that is easy to interpret.

Usage

rich.colors(n, palette="temperature", rgb.matrix=FALSE,
            plot.colors=FALSE)

Arguments

n
number of colors to generate.
palette
palette to use: "temperature" contains blue-green-yellow-red, and "blues" contains black-blue-white.
rgb.matrix
if TRUE then a matrix of RGB values is included as an attribute.
plot.colors
if TRUE then a descriptive color diagram is plotted on the current device.

Value

  • A character vector of color codes.

See Also

rgb, rainbow, heat.colors.

Examples

Run this code
m <- matrix(1:120+rnorm(120), nrow=15, ncol=8)
opar <- par(bg="gray", mfrow=c(1,2))
matplot(m, type="l", lty=1, lwd=3, col=rich.colors(8))
matplot(m, type="l", lty=1, lwd=3, col=rich.colors(8,"blues"))
par(opar)

barplot(rep(1,100), col=rich.colors(100), space=0, border=0, axes=FALSE)
barplot(rep(1,20), col=rich.colors(40)[11:30]) # choose subset

rich.colors(100, plot=TRUE, rgb=TRUE)  # describe rgb recipe

par(mfrow=c(2,2))
barplot(m, col=heat.colors(15), main="heat.colors")
barplot(m, col=1:15, main="default palette")
barplot(m, col=rich.colors(15), main="rich.colors")
barplot(m, col=rainbow(15), main="rainbow")
par(opar)

Run the code above in your browser using DataLab