Ggplot: Recommended Colour Palettes Also Distinguishable for B&W Printing

ggplot: recommended colour palettes also distinguishable for B&W printing?

Use http://colorbrewer2.org/ and only show colour schemes that are printer friendly.
Also see scale_fill_grey.

Currently it's not possible to used hash lines due to a limitation in the underlying grid drawing package.

Colour palette that works in colour and in greyscale?

I think it could help to see the palettes in both raw and black&white version, like this (or with other palettes)

Sample Image

R color palettes for many data classes

Try '?colorRampPalette' and make your own function.

How to produce a heatmap with ggplot2?

To be honest @dr.bunsen - your example above was poorly reproducable and you didn't read the first part of the tutorial that you linked. Here is probably what you are looking for:

 library(reshape)
library(ggplot2)
library(scales)

data <- structure(list(people = structure(c(2L, 3L, 1L, 4L),
.Label = c("bill", "mike", "sue", "ted"),
class = "factor"),
apple = c(1L, 0L, 3L, 1L),
orange = c(0L, 0L, 3L, 1L),
peach = c(6L, 1L, 1L, 0L)),
.Names = c("people", "apple", "orange", "peach"),
class = "data.frame",
row.names = c(NA, -4L))
data.m <- melt(data)
data.m <- ddply(data.m, .(variable), transform, rescale = rescale(value))
p <- ggplot(data.m, aes(variable, people)) +
geom_tile(aes(fill = rescale), colour = "white")
p + scale_fill_gradient(low = "white", high = "steelblue")

Sample Image

R Plot Color Combinations that Are Colorblind Accessible

Okabe-Ito palette

The palette shown in the question is also known as the Okabe-Ito palette as suggested by Okabe & Ito (2008). Since version 4.0.0, base R provides a new palette.colors() where this palette is actually the default:

palette.colors(palette = "Okabe-Ito")
## black orange skyblue bluishgreen yellow
## "#000000" "#E69F00" "#56B4E9" "#009E73" "#F0E442"
## blue vermillion reddishpurple gray
## "#0072B2" "#D55E00" "#CC79A7" "#999999"

Qualitative palettes in base R

Along with this palette, various other qualitative palettes are easily available in base R. Specifically, the new default palette (called "R4") has also been designed to be rather robust under color vision deficiencies. See this blog post for further details:

  • Zeileis, Murrell, Maechler, Sarkar (2019). "A New palette() for R." The R Blog.

overview of various palettes in the palette.colors function

Sequential and diverging palettes in base R

In addition to the qualitative palettes above, base R also has a new function hcl.colors() since version 3.6.0 that makes many sequential and diverging palettes available that are also robust under color vision deficiencies. It provides approximations (derived using the hue-chroma-luminance color model) to many palettes from ColorBrewer.org, viridis, CARTO colors, Crameri's scientific colors etc. The default is the popular viridis palette. The following blog post provides more details and the paper about the colorspace package explains more related/underlying work.

  • Zeileis, Murrell (2019). "HCL-Based Color Palettes in grDevices." The R Blog.
  • Zeileis, Fisher, Hornik, Ihaka, McWhite, Murrell, Stauffer, Wilke (2020). "colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes." Journal of Statistical Software.

overview of sequential palettes in the hcl.colors function

overview of diverging palettes in the hcl.colors function



Related Topics



Leave a reply



Submit