Skip to contents

The original openair package contained the openair::openColours() function which made many common colour palettes easily available. This is a ggplot2 scale wrapper around this function similar to ggplot2::scale_color_viridis_c(). Unlike other ggplot2 colour scale functions, the aesthetics argument defaults to both "fill" and "colour", meaning scales can be used with any ggopenair plotting function.

Usage

scale_opencolours_d(..., scheme = "default", aesthetics = c("colour", "fill"))

scale_opencolours_c(
  ...,
  scheme = "default",
  values = NULL,
  space = "Lab",
  na.value = "grey50",
  guide = "colourbar",
  aesthetics = c("colour", "fill")
)

scale_opencolours_b(
  ...,
  scheme = "default",
  values = NULL,
  space = "Lab",
  na.value = "grey50",
  guide = "coloursteps",
  aesthetics = c("colour", "fill")
)

Arguments

...

Other arguments passed on to ggplot2::discrete_scale(), ggplot2::continuous_scale(), or ggplot2::binned_scale() to control name, limits, breaks, labels and so forth.

scheme

The pre-defined schemes are "increment", "default", "brewer1", "heat", "jet", "turbo", "hue", "greyscale", or a vector of R colour names e.g. c("green", "blue"). It is also possible to supply colour schemes from the RColorBrewer package. This package defines three types of colour schemes: sequential, diverging or qualitative. See https://colorbrewer2.org/ for more details concerning the original work on which this is based.

Simplified versions of the viridis colours are also available. These include "viridis", "plasma", "magma", "inferno" and "cividis".

Sequential colours are useful for ordered data where there is a need to show a difference between low and high values with colours going from light to dark. The pre-defined colours that can be supplied are: "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd".

Diverging palettes put equal emphasis on mid-range critical values and extremes at both ends of the data range. Pre-defined values are: "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral".

Qualitative palettes are useful for differentiating between categorical data types. The pre-defined schemes are "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", "Set1", "Set2", "Set3".

A colour-blind safe palette "cbPalette" is available based on the work of: https://www.nature.com/articles/nmeth.1618

The colour's associated with the UK daily air quality index are also available using "daqi" (a palette of 10 colours, corresponding to each index value) or "daqi.bands" (4 colours, corresponding to each band - Low, Moderate, High, and Very High). These colours were taken directly from https://uk-air.defra.gov.uk/air-pollution/daqi and may be useful in figures like calendarPlot().

Note that because of the way these 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.

aesthetics

Character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with. This can be useful, for example, to apply colour settings to the colour and fill aesthetics at the same time, via aesthetics = c("colour", "fill").

values

if colours should not be evenly positioned along the gradient this vector gives the position (between 0 and 1) for each colour in the colours vector. See rescale() for a convenience function to map an arbitrary range to between 0 and 1.

space

colour space in which to calculate gradient. Must be "Lab" - other values are deprecated.

na.value

Missing values will be replaced with this value.

guide

A function used to create a guide or its name. See guides() for more information.

See also

The documentation on colour aesthetics.