colour_ramp {scales} | R Documentation |
Fast colour interpolation
Description
Returns a function that maps the interval [0,1] to a set of colours.
Interpolation is performed in the CIELAB colour space. Similar to
colorRamp(space = 'Lab')
, but hundreds of
times faster, and provides results in "#RRGGBB"
(or
"#RRGGBBAA"
) character form instead of RGB colour matrices.
Usage
colour_ramp(colors, na.color = NA, alpha = TRUE)
Arguments
colors |
Colours to interpolate; must be a valid argument to
|
na.color |
The colour to map to |
alpha |
Whether to include alpha transparency channels in interpolation.
If |
Value
A function that takes a numeric vector and returns a character vector of the same length with RGB or RGBA hex colours.
See Also
Examples
ramp <- colour_ramp(c("red", "green", "blue"))
show_col(ramp(seq(0, 1, length = 12)))