Learn R Programming

khroma (version 1.14.0)

palette_color_picker: 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, ... )

Value

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

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().

See Also

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

Examples

Run this code
## 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)

Run the code above in your browser using DataLab