gradient {shades} | R Documentation |
Colour gradients
Description
This function returns a set of colours interpolating between the specified key colours, equally separated in the specified space.
Usage
gradient(shades, steps = NULL, space = NULL)
Arguments
shades |
Two or more colours, in any suitable form (see
|
steps |
An integer giving the number of shades required in the palette.
If |
space |
The colour space to traverse. Defaults to the current space of
|
Details
The key colours may be specified explicitly, or else a built-in colour map
may be used. The maps available are currently those developed for Python's
matplotlib
2.0, namely "magma"
, "inferno"
,
"plasma"
and "viridis"
, and certain ColorBrewer palettes,
namely "Blues"
, "Reds"
, "YlOrRd"
(yellow-orange-red)
and "RdBu"
(red-grey-blue, a balanced diverging scale).
Value
A character vector of class "shade"
containing the gradient
elements in the specified space, or a palette function.
Author(s)
Jon Clayden <code@clayden.org>
References
http://bids.github.io/colormap/ for the matplotlib
colour maps;
http://colorbrewer2.org for the ColorBrewer ones.
Examples
gradient(c("red","blue"), 5)
gradient(c("red","blue"), 5, space="Lab")
gradient("viridis", 5)