InterpolateColorFun {colorpatch}R Documentation

Linear interpolation within a colorspace::color palette

Description

This function can be used together with ggplot2 for mapping values onto colorspace::color palettes. The color is then coerced with coerce.fun.

Usage

InterpolateColorFun(pal, xmin = -1, xmax = +1,
  coerce.fun = colorspace::hex)

Arguments

pal

The input palette (must be of class colorspace::color)

xmin

minimum of the numeric range to be mapped onto pal

xmax

maximum of the numeric range to be mapped onto pal

coerce.fun

each color will be coerced by this function (defaults to colorspace::hex())

Value

A function mapping a numeric value value onto a color value.

Examples

library(colorspace)
library(colorpatch)
data("OptimGreenRedLAB")
fn <- InterpolateColorFun(OptimGreenRedLAB)
cols <- fn(seq(-1, 1, by = 0.1))
specplot(cols)

[Package colorpatch version 0.1.2 Index]