palette_color_picker: Color Mapping

View source: R/palettes.R

palette_color_pickerR Documentation

Color Mapping

Description

Maps values to colors.

Usage

palette_color_picker(
  scheme,
  domain = NULL,
  midpoint = NULL,
  ordered = FALSE,
  missing = NULL,
  ...
)

palette_colour_picker(
  scheme,
  domain = NULL,
  midpoint = NULL,
  ordered = FALSE,
  missing = NULL,
  ...
)

Arguments

scheme

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

domain

A numeric range or a vector of categorical data specifying the possible values that can be mapped.

midpoint

A length-one numeric vector specifying the mid-point of input range.

ordered

A logical scalar: should the levels be treated as already in the correct order?

missing

The color to return for NA values.

...

Further parameters to be passed to color().

Details

A wrapper around palette_color_continuous() and palette_color_discrete().

Value

A palette function that when called with a single argument returns a character vector of colors.

See Also

Other palettes: palette_color_continuous(), palette_color_discrete(), palette_shape(), palette_size_range()

Examples

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

## Where are breaks?
elevation$breaks

## Build palette functions
ramp_BuRd <- palette_color_picker("BuRd")

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

## Rescale to midpoint
ramp_BuRd <- palette_color_picker("BuRd", midpoint = 160)

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

khroma documentation built on Sept. 11, 2024, 5:26 p.m.