Learn R Programming

khroma (version 1.1.1)

scale_colour_tol: Paul Tol's Colour Schemes for ggplot2

Description

Provides qualitative, diverging and sequential colour scales from Paul Tol's Colour Schemes.

Usage

scale_colour_tol(..., palette, reverse = FALSE, aesthetics = "colour")

scale_color_tol(..., palette, reverse = FALSE, aesthetics = "colour")

scale_fill_tol(..., palette, reverse = FALSE, aesthetics = "fill")

Arguments

...

Arguments passed to discrete_scale or continuous_scale, used respectively for qualitative data and diverging/sequential data.

palette

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

reverse

A logical scalar specifying if the resulting vector of colours should be reversed.

aesthetics

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

Details

These methods are deprecated, use scale_tol_discrete, scale_tol_diverging or scale_tol_sequential instead.

Paul Tol provides colour schemes ready for each type of data, with colours that are :

  • distinct for all people, including colour-blind readers;

  • distinct from black and white;

  • distinct on screen and paper;

  • matching well together.

The qualitative colour schemes are used as given: colours are picked at random up to the maximum number of supported values (in brackets). Diverging and sequential colour schemes are linearly interpolated. The following palettes are available:

Qualitative data

bright (7), vibrant (7), muted (9), light (9), rainbow (23)

Diverging data

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

Sequential data

YlOrBr (9), smooth rainbow (34)

References

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

Examples

Run this code
# NOT RUN {
  library(ggplot2)

  # Qualitative data
  ggplot(mpg, aes(displ, hwy, colour = class)) +
    geom_point() +
    khroma::scale_colour_tol(palette = "bright")

  ggplot(diamonds, aes(clarity, fill = cut)) +
    geom_bar() +
    khroma::scale_fill_tol(palette = "vibrant")

  # Diverging data
  ggplot(economics, aes(psavert, pce, colour = unemploy)) +
    geom_point() +
    khroma::scale_color_tol(palette = "sunset")

  # Sequential data
  ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
    geom_raster() +
    khroma::scale_fill_tol(palette = "YlOrBr", reverse = TRUE)
# }

Run the code above in your browser using DataLab