as.colorRampPalette: Color Interpolation

as.colorRampPaletteR Documentation

Color Interpolation

Description

Create a function that interpolates a set of colors to produce new color palettes.

Usage

as.colorRampPalette(...)

Arguments

...

arguments to pass to colorRamp.

Details

This is a preferable alternative to colorRampPalette since the returned function has more arguments. The returned function has arguments start, end, alpha, and rev, similar to rainbow or viridis.colors.

If only one argument is provided that happens to be a function, it is assumed that this function is the function that maps the interval [0,1] to a series of colors, and so the argument will not be passed to colorRamp.

Value

A function which takes an integer n and returns a character vector of n colors.

Examples

crp <- as.colorRampPalette(1:9)

show.colors(crp(20))

show.colors(crp(20, end = 19/20))

show.colors(crp(20, alpha = 0.75))

show.colors(crp(20, rev = TRUE))

show.colors(crp(20, end = 19/20, alpha = 0.75, rev = TRUE))

ArcadeAntics/essentials documentation built on Nov. 7, 2024, 4:33 p.m.