colorRamp
Ramp/Interpolate Colors
Description
Generates functions that interpolate the given colors to create new color ramps and palettes.
Usage
colorRamp(colors, bias = 1, space = c("rgb", "Lab"),
interpolate = c("linear", "spline"))
colorRampPalette(colors, ...)
Arguments
colors |
a vector of color names, or an "##rrggbb"/"##rrggbbaa" format string representing colors,
or integers representing the color index of the palette table.
|
bias |
a positive number.
The interpolating function places the input color values at positions
seq(0, 1, length.out=length(colors)) ^ bias on the x axis.
When bias is 1 (the default), the input colors are equally spaced.
|
space |
a character string specifying the interpolation in an sRGB or Lab color space.
This argument is currently ignored: the interpolation is always done in an sRGB color space.
|
interpolate |
a character string specifying the "linear" or "spline" interpolation method.
|
... |
all remaining arguments to colorRampPalette are passed to colorRamp
to control how the colors are interpolated.
|
Details
approxfun or splinefun is used for the "linear" or "spline" interpolation method.
Value
colorRamp | returns a function that maps the values between 0 and 1 to a 3- (or 4- if
alpha is TRUE) column matrix of numbers between 0 and 255, specifying
the values of the red, green, and blue components of the interpolated color (and the
opacity value if alpha is TRUE). There is one row per input color. |
colorRampPalette | returns a function that maps a positive integer, n, to a
n-long character vector specifying n colors that interpolate between the input colors.
The returned colors are in the hexadecimal color format "#RRGGBB" (or "RRGGBBAA"
if alpha is TRUE). |
See Also
Examples
colorRamp(c("green", "yellow", "red"))(0:4/4)
colorRampPalette(c("green", "yellow", "red"))(5)
colorRamp(c("#00ff0000", "#ffff00af", "#ff0000ff"), alpha=TRUE, interp="spline")((0:10)/10)
colorRamp(c("red", "yellow", "green", "cyan"), bias=1/3)((0:10)/10)