Learn R Programming

khroma (version 1.3.0)

scale_tol_diverging: Paul Tol's Diverging Colour Schemes for ggplot2

Description

Provides diverging colour scales from Paul Tol's Colour Schemes.

Usage

scale_colour_sunset(..., reverse = FALSE, midpoint = 0,
  aesthetics = "colour")

scale_color_sunset(..., reverse = FALSE, midpoint = 0, aesthetics = "colour")

scale_fill_sunset(..., reverse = FALSE, midpoint = 0, aesthetics = "fill")

scale_colour_BuRd(..., reverse = FALSE, midpoint = 0, aesthetics = "colour")

scale_color_BuRd(..., reverse = FALSE, midpoint = 0, aesthetics = "colour")

scale_fill_BuRd(..., reverse = FALSE, midpoint = 0, aesthetics = "fill")

scale_colour_PRGn(..., reverse = FALSE, midpoint = 0, aesthetics = "colour")

scale_color_PRGn(..., reverse = FALSE, midpoint = 0, aesthetics = "colour")

scale_fill_PRGn(..., reverse = FALSE, midpoint = 0, aesthetics = "fill")

Arguments

...

Arguments passed to continuous_scale.

reverse

A logical scalar. Should the resulting vector of colours be reversed?

midpoint

A length-one numeric vector giving the midpoint (in data value) of the diverging scale. Defaults to 0.

aesthetics

A character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with.

Value

A continuous scale.

Details

If more colours than defined are needed from a given scheme, the colour coordinates are linearly interpolated to provide a continuous version of the scheme. Note that the default colour for NA can be overridden by passing a value to continuous_scale.

Palette Max. colours NA value
sunset 11 #FFFFFF
BuRd 9 #FFEE99
PRGn 9 #FFEE99

References

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

See Also

Other Paul Tol's colour schemes: scale_tol_discrete, scale_tol_sequential

Examples

Run this code
# NOT RUN {
library(ggplot2)

ggplot2::ggplot(economics, ggplot2::aes(psavert, pce, colour = unemploy)) +
  ggplot2::geom_point() +
  scale_color_sunset(midpoint = 12000)

ggplot2::ggplot(economics, ggplot2::aes(psavert, pce, colour = unemploy)) +
  ggplot2::geom_point() +
  scale_color_BuRd(midpoint = 9000)

ggplot2::ggplot(economics, ggplot2::aes(psavert, pce, colour = unemploy)) +
  ggplot2::geom_point() +
  scale_color_PRGn(midpoint = 6000)
# }

Run the code above in your browser using DataLab