color.scale {plotrix}R Documentation

Turn values into colors.

Description

Transform numeric values into colors.

Usage

 color.scale(x,redrange,greenrange,bluerange)

Arguments

x a numeric vector, matrix or data frame
redrange,greenrange,bluerange color ranges into which to scale x

Details

color.scale calculates a sequence of colors by a linear transformation of the numeric values supplied into the ranges for red, green and blue. If only one number is supplied for a color range, that color remains constant for all values of x. If more than two values are supplied, the x values will be split into equal ranges (one less than the number of colors) and the transformation carried out on each range. Values for a color range must be between 0 and 1.

Value

A vector or matrix of hexadecimal color values.

Note

The function is useful for highlighting a numeric dimension or adding an extra "dimension" to a plot.

Author(s)

Jim Lemon

See Also

rescale

Examples

 # go from green through yellow to red with no blue
 x<-rnorm(20)
 y<-rnorm(20)
 # use y for the color scale
 plot(x,y,col=color.scale(y,c(0,1,1),c(1,1,0),0),main="Color scale plot",
  pch=16,cex=2)

[Package plotrix version 2.2 Index]