Skip to contents

This in primarily an internal openair function to make it easy for users to select particular colour schemes, or define their own range of colours of a user-defined length.

Usage

openColours(scheme = "default", n = 100)

Arguments

scheme

Any one of the pre-defined openair schemes (e.g., "increment") or a user-defined palette (e.g., c("red", "orange", "gold")). See ?openColours for a full list of available schemes.

n

number of colours required.

Value

A character vector of hex codes

Schemes

The following schemes are made available by openColours():

Sequential Colours:

  • "default", "increment", "brewer1", "heat", "jet", "turbo", "hue", "greyscale".

  • Simplified versions of the viridis colours: "viridis", "plasma", "magma", "inferno", "cividis", and "turbo".

  • Simplified versions of the RColorBrewer sequential palettes: "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd".

Diverging Palettes:

  • Simplified versions of the RColorBrewer diverging palettes: "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral".

Qualitative Palettes:

UK Government Palettes:

Details

Because of the way many of the schemes have been developed they only exist over certain number of colour gradations (typically 3–10) — see ?brewer.pal for actual details. If less than or more than the required number of colours is supplied then openair will interpolate the colours.

Each of the pre-defined schemes have merits and their use will depend on a particular situation. For showing incrementing concentrations, e.g., high concentrations emphasised, then "default", "heat", "jet", "turbo", and "increment" are very useful. See also the description of RColorBrewer schemes for the option scheme.

To colour-code categorical-type problems, e.g., colours for different pollutants, "hue" and "brewer1" are useful.

When publishing in black and white, "greyscale" is often convenient. With most openair functions, as well as generating a greyscale colour gradient, it also resets strip background and other coloured text and lines to greyscale values.

Failing that, the user can define their own schemes based on R colour names. To see the full list of names, type colors() into R.

Author

David Carslaw

Jack Davison

Examples


# to return 5 colours from the "jet" scheme:
cols <- openColours("jet", 5)
cols
#> [1] "#00007F" "#007FFF" "#7FFF7F" "#FF7F00" "#7F0000"

# to interpolate between named colours e.g. 10 colours from yellow to
#  green to red:
cols <- openColours(c("yellow", "green", "red"), 10)
cols
#>  [1] "#FFFF00" "#C6FF00" "#8DFF00" "#55FF00" "#1CFF00" "#1CE200" "#54AA00"
#>  [8] "#8D7100" "#C63800" "#FF0000"