Learn R Programming

plotrix (version 2.1-5)

color.gradient: Calculate an arbitrary sequence of colors.

Description

color.gradient calculates sequences of colors by linearly interpolating between the values specified for each color. If the length of a vector of colors is the same as nslices it is not changed. If any length is greater than nslices, it is truncated to that length. If any color values are less than 0 or greater than 1, they are rescaled to that range.

Usage

color.gradient(reds,greens,blues,nslices=50)

Arguments

reds,greens,blues
vectors of the values of the color components as 0 to 1.
nslices
The number of color "slices".

Value

  • A vector of hexadecimal color values as used by col.

See Also

rescale,approx,color.scale

Examples

Run this code
# try it with red endpoints, green midpoints, and a blue vector longer
 # than 'nslices'
 color.gradient(c(0,1),c(1,0.6,0.4,0.3,0),seq(0.1,0.6,length=60))

Run the code above in your browser using DataLab