InterpolateColorFun: Linear interpolation within a colorspace::color palette

Description Usage Arguments Value Examples

View source: R/colorpatch_impl.R

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

1
2
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

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

colorpatch documentation built on May 1, 2019, 10:28 p.m.