Skip to content
Colour Schemes for Scientific Data Visualization
R
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add an issue template and pull request template Aug 17, 2019
R Rename internal data sets Aug 17, 2019
data-raw Rename internal data sets Aug 17, 2019
inst Prepare for next release (1.2.0) Aug 16, 2019
man Prepare for next release (1.2.0) Aug 16, 2019
tests Test attributes of the palette functions Aug 16, 2019
vignettes Update README Aug 16, 2019
.Rbuildignore Add a Code of Conduct Aug 16, 2019
.gitignore Change version number to 1.1.3.9000 Jun 7, 2019
.travis.yml Depend on R 3.2 Aug 16, 2019
.zenodo.json Update package keywords Aug 17, 2019
DESCRIPTION Prepare for next release (1.2.0) Aug 16, 2019
LICENSE.md Change LICENSE to a markdown document Mar 19, 2019
NAMESPACE Add plot_scheme() and plot_map() to display colour schemes Jul 28, 2019
NEWS.Rmd Prepare for next release (1.2.0) Aug 16, 2019
NEWS.md Prepare for next release (1.2.0) Aug 16, 2019
README.Rmd Add a Code of Conduct Aug 16, 2019
README.md Add a Code of Conduct Aug 16, 2019
_pkgdown.yml
appveyor.yml Update CI configs Jun 5, 2019
codecov.yml
codemeta.json Update package keywords Aug 17, 2019
cran-comments.md
khroma.Rproj Add RStudio project file Oct 12, 2018

README.md

khroma

Appveyor build status Travis build Status codecov

CRAN Version CRAN checks CRAN Downloads

Project Status: Active – The project has reached a stable, usable state and is being actively developed. lifecycle

DOI

Overview

Color blindness affects a large number of individuals. When communicating scientific results colour palettes must therefore be carefully chosen to be accessible to all readers.

This R package provides an implementation of Paul Tol’s colour schemes [1]. These schemes are ready for each type of data (qualitative, diverging or sequential), with colours that are distinct for all people, including colour-blind readers. This package also provides tools to simulate colour-blindness and to test how well the colours of any palette are identifiable. To simulate colour-blindness in production-ready R figures you may also be interested in the colorblindr package.

For specific uses, several scientific thematic schemes (geologic timescale, land cover, FAO soils, etc.) are implemented, but these colour schemes may not be colour-blind safe.

All these colour schemes are implemented for use with base R graphics or ggplot2.

Installation

Install the released version of khroma from CRAN:

install.packages("khroma")

Or install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("nfrerebeau/khroma")

Usage

Colour palettes and scales

library(khroma)

# colour() returns a palette function
bright <- colour("bright")
# that when called with a single integer argument returns a vector of colours
bright(7)
#>      blue       red     green    yellow      cyan    purple      grey 
#> "#4477AA" "#EE6677" "#228833" "#CCBB44" "#66CCEE" "#AA3377" "#BBBBBB"

# Show the colour palette
plot_scheme(bright(7), colours = TRUE)

library(ggplot2)

# Use with ggplot2
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, colour = class)) +
  geom_point() +
  scale_colour_bright()

Diagnostic tools

# Test how well the colours are identifiable
plot_map(bright(7))

# Simulate colour-blindness
# convert() returns a modified palette function
deuteranopia <- convert(bright, mode = "deuteranopia")
plot_scheme(deuteranopia(7), colours = TRUE)

protanopia <- convert(bright, mode = "protanopia")
plot_scheme(protanopia(7), colours = TRUE)

tritanopia <- convert(bright, mode = "tritanopia")
plot_scheme(tritanopia(7), colours = TRUE)

achromatopsia <- convert(bright, mode = "achromatopsia")
plot_scheme(achromatopsia(7), colours = TRUE)

Colour Schemes

Paul Tol’s Colour Schemes

Paul Tol offers carefully chosen 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.

All the scales presented in Paul Tol’s technical note are implemented here, for use with graphics or ggplot2. Refer to the original document for details about the recommended uses.

See the vignette for a more complete overview:

utils::vignette("tol")

Scientific colour schemes

The following scientific colour schemes are available:

  • International Chronostratigraphic Chart.
  • AVHRR Global Land Cover Classification.
  • FAO Soil Reference Groups.

More will be added in future releases (suggestions are welcome).

Contributing

Please note that the ‘khroma’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

  1. Tol, Paul (2018). Colour Schemes. SRON. Technical Note No. SRON/EPS/TN/09-002. URL: https://personal.sron.nl/~pault/data/colourschemes.pdf.
You can’t perform that action at this time.