Learn R Programming

khroma (version 1.3.0)

colour: Colour Palette

Description

Provides qualitative, diverging and sequential colour schemes.

Usage

colour(palette, reverse = FALSE, names = TRUE, ...)

color(palette, reverse = FALSE, names = TRUE, ...)

Arguments

palette

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

reverse

A logical scalar: should the resulting vector of colours should be reversed?

names

A logical scalar: should the names of the colours should be kept in the resulting vector?

...

Further arguments passed to colorRampPalette.

Value

A palette function with the following attributes, that when called with a single integer argument (the number of levels) returns a (named) vector of colours.

name

A character string giving the name of the colour scheme.

type

A character string giving the corresponding data type. One of "qualitative", "diverging" or "sequential".

interpolate

A logical scalar: can the color palette be interpolated?

missing

A character string giving the the hexadecimal representation of the colour that should be used for NA values.

max

An integer giving the maximum number of colour values. Only relevant for non-interpolated colour schemes.

Paul Tol's Colour Schemes

The following palettes are available. The maximum number of supported colours is in brackets, this value is only relevant for the qualitative colour schemes (divergent and sequential schemes are linearly interpolated).

Qualitative data

bright (7), contrast (3), vibrant (7), muted (9), pale (6), dark (6), light (9).

Diverging data

sunset (11), BuRd (9), PRGn (9).

Sequential data

YlOrBr (9), iridescent (23), discrete rainbow (23), smooth rainbow (34).

Qualitative colour schemes

According to Paul Tol's technical note, the bright, contrast, vibrant and muted colour schemes are colour-blind safe.

The light colour scheme is reasonably distinct for both normal or colour-blind vision and is intended to fill labelled cells.

The pale and dark schemes are not very distinct in either normal or colour-blind vision and should be used as a text background or to highlight a cell in a table.

Refer to the original document for details about the recommended uses (see references).

Rainbow colour scheme

As a general rule, ordered data should not be represented using a rainbow scheme. There are three main arguments against such use (Tol 2018):

  • The spectral order of visible light carries no inherent magnitude message.

  • Some bands of almost constant hue with sharp transitions between them, can be perceived as jumps in the data.

  • Colour-blind people have difficulty distinguishing some colours of the rainbow.

If such use cannot be avoided, Paul Tol's technical note provides two colour schemes that are reasonably clear in colour-blind vision. To remain colour-blind safe, these two schemes must comply with the following conditions:

discrete rainbow

This scheme must not be interpolated.

smooth rainbow

This scheme does not have to be used over the full range.

Scientific Colour Schemes

The following (qualitative) colour schemes are available:

stratigraphy

International Chronostratigraphic Chart (175 colours).

land

AVHRR Global Land Cover Classification (14 colours).

soil

FAO Reference Soil Groups (24 colours).

References

Jones, A., Montanarella, L. & Jones, R. (Ed.) (2005). Soil atlas of Europe. Luxembourg: European Commission, Office for Official Publications of the European Communities. 128 pp. ISBN: 92-894-8120-X.

Tol, P. (2018). Colour Schemes. SRON. Technical Note No. SRON/EPS/TN/09-002, issue 3.1. URL: https://personal.sron.nl/~pault/data/colourschemes.pdf

Commission for the Geological Map of the World

Examples

Run this code
# NOT RUN {
## Paul Tol's colour schemes
### Qualitative data
plot_scheme(colour("bright")(7))
plot_scheme(colour("contrast")(3))
plot_scheme(colour("vibrant")(7))
plot_scheme(colour("pale")(6))
plot_scheme(colour("dark")(6))
plot_scheme(colour("muted")(9))
plot_scheme(colour("light")(9))
### Diverging data
plot_scheme(colour("sunset")(11))
plot_scheme(colour("BuRd")(9))
plot_scheme(colour("PRGn")(9))
### Sequential data
plot_scheme(colour("YlOrBr")(9))
plot_scheme(colour("iridescent")(23))
plot_scheme(colour("discrete rainbow")(14))
plot_scheme(colour("discrete rainbow")(23))
plot_scheme(colour("smooth rainbow")(34))

## Scientific colour schemes
### Geologic timescale
plot_scheme(colour("stratigraphy")(175))
### AVHRR global land cover classification
plot_scheme(colour("land")(14))
### FAO soil reference groups
plot_scheme(colour("soil")(24))
# }

Run the code above in your browser using DataLab