gradient: Colour gradients

Description Usage Arguments Details Value Author(s) References Examples

Description

This function returns a set of colours interpolating between the specified key colours, equally separated in the specified space.

Usage

1
gradient(shades, steps = NULL, space = NULL)

Arguments

shades

Two or more colours, in any suitable form (see shade), or a named colour map such as "viridis".

steps

An integer giving the number of shades required in the palette. If NULL, a function will instead be returned that takes this argument.

space

The colour space to traverse. Defaults to the current space of shades, or "Lab" for the matplotlib colour maps, or "sRGB" otherwise.

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

1
2
3
gradient(c("red","blue"), 5)
gradient(c("red","blue"), 5, space="Lab")
gradient("viridis", 5)

Example output

 5 shades in sRGB space, without transparency
[1] #FF0000 #BF0040 #800080 #4000BF #0000FF
 5 shades in Lab space, without transparency
[1] #FF0000 #E80050 #C90089 #9A00C3 #0000FF
 5 shades in Lab space, without transparency
[1] #440154 #3B528B #22908D #5FC863 #FDE725

shades documentation built on Aug. 2, 2019, 5:05 p.m.