ramp: Color Ramp

View source: R/ramp.R

rampR Documentation

Color Ramp

Description

Provides a color scheme that map a numeric vector to colors.

Usage

ramp(palette, ...)

Arguments

palette

A character string giving the name of the palette to be used (see color()).

...

Further arguments to be passed to color().

Value

A palette function with argument a vector of values that are mapped to colors. The data midpoint can be specified with an additional midpoint argument (see examples).

Author(s)

N. Frerebeau

See Also

Other color palettes: colour(), info(), scale_picker

Examples

## Visualize a simple DEM model
## Distribution of elevation values
elevation <- hist(volcano)

## Where are breaks?
elevation$breaks

## Build palette function
ramp_BuRd <- ramp(palette = "BuRd")

(col <- ramp_BuRd(elevation$breaks))
image(volcano, col = col)
legend("topright", legend = attr(col, "breaks"), fill = col)

## Rescale to midpoint
(col <- ramp_BuRd(elevation$breaks, midpoint = 160))
image(volcano, col = col)
legend("topright", legend = attr(col, "breaks"), fill = col)

khroma documentation built on Aug. 21, 2023, 5:11 p.m.