Somewhere over the Rainbow

Overview

The go-to palette in many software packages is - or used to be until rather recently - the so-called rainbow: a palette created by changing the hue in highly-saturated RGB colors. This has been widely recognized as having a number of disadvantages including: abrupt shifts in brightness, misleading for viewers with color vision deficiencies, too flashy to look at for a longer time. See also the article on color vision deficiencies which compares the infamous RGB rainbow with better HCL-based alternatives using demoplot(). Here, we provide further rainbow examples taken from actual publications (rather than simplified demos).

For more details on the limitations of the rainbow palette and further pointers see “The End of the Rainbow” by Hawkins et al. [4], “Examining Implicit Discretization in Spectral Schemes” by Quinan et al. [8], or “Somewhere over the Rainbow: How to Make Effective Use of Colors in Meteorological Visualizations” by Stauffer et al. [10] as well as the #endrainbow hashtag on Twitter.

In a nutshell, the (in-)famous RGB rainbow palette is virtually always a poor choice and properly balanced qualitative, sequential, or diverging palettes - such as the HCL-Based Color Palettes provided here - are preferable. Despite such alternatives becoming more and more widely available the rainbow palette is unfortunately still widely used. Below we illustrate some wild-caught examples, highlight their problems (e.g., by desaturation to grayscale or by emulating color vision deficiencies), and suggest better alternatives.

Would Bob Ross approve?

When you see a (scientific) data visualization with a rainbow, ask yourself: Would Bob Ross approve of this?

../_images/bobross.jpg

Most likely not. In contrast, choosing a HCL-based palette instead will yield less flashy colors that change smoothly … very much in the spirit of The Joy of Painting.

Heatmap from The Grammar of Graphics

Even in the excellent book “The Grammar of Graphics” by Wilkinson [14], the rainbow palette is used in one of the first figures, depicting a heatmap of a bivariate kernel density estimate. The figure is shown below on the left and is contrasted with an HCL-based sequential heat color palette on the right (sequential_hcl("Heat")(99)).

../_images/bkde-rainbow.png ../_images/bkde-heat.png

The original palette changes back and forth between dark and light colors and hence high- and low-density regions are difficult to tell apart, especially when desaturated to grayscale. In contrast, the heat colors go from light to dark and still work very well in grayscale.

../_images/bkde-rainbow-gray.png ../_images/bkde-heat-gray.png

Similarly, high- and low-density regions are much harder to distinguish for colorblind viewers in the original rainbow palette compared to the heat colors. Below deuteranope vision is emulated.

../_images/bkde-rainbow-deutan.png ../_images/bkde-heat-deutan.png

Map of model deviations

Often a subset of the RGB rainbow palette is used as a “traffic light”, coding “positive” (green) and “negative” (red) deviations from some neutral value (yellow), e.g., forecast errors or other model deviations, correlations, slopes, etc. A typical example is shown below, taken from Figure 5 of Kneib [5], where deviations from a childhood moratlity model (without spatial effect) for Nigeria are depicted.

The original palette is rainbow(start = 0, end = 1/3, rev = True)(99) (left) and as a better alternative diverging_hcl("Purple-Green", rev = True)(99) is used. This avoids the flashy colors and uses light gray as the neutral value, making it easier to look at the display for a longer time. Instead of diverging to red/green the palette diverges to purple/green as this works better for colorblind viewers (see below).

../_images/nigeria-rainbow.png ../_images/nigeria-purplegreen.png

Emulating protanope vision most of the green-yellow contrasts in the RGB rainbow are collpased, making the plot very misleading while the HCL-based purple/green palette still works very well for colorblind viewers.

../_images/nigeria-rainbow-protan.png ../_images/nigeria-purplegreen-protan.png

Another important difference between the two palettes is that the HCL-based alternative is completely balanced between the two “arms” of the palette while the rainbow is not. Specifically, the green arm has an almost flat luminance trajectory while the red arm reaches much lower luminances (i.e., darker colors).

(Source code, png, hires.png, pdf)

../_images/endrainbow-1.png

(Source code, png, hires.png, pdf)

../_images/endrainbow-2.png

Weather map: Dewpoint temperature

Another shaded map for communicating a weather forecast is shown below, depicting dewpoint temperature forecasts from a certain FV3 Global Forecast System (GFS) product. It also does not use a standard rainbow but a palette of similarly highly-saturated colors from a wide range of hues (left panel).

As in the previous section, the palette is very discontinuous and breaks the values down into separate “classes” or “bands”. For experienced users this may help locating bands with very specific numeric values but leads to an uneven overall picture. In contrast, the sequential_hcl("ag_Sunset").colors(23) palette (right panel) shows a smooth gradient, giving somewhat more emphasis to the darker low-temperature regions.

../_images/fv3gfs-rainbow.png ../_images/fv3gfs-sunset.png

Depicting the hue/chroma/luminance trajectories of both palettes also shows the abrupt changes in the original palette which do not convey a continuous temperature scale. Instead, the HCL-based sunset palette is also built from a wide range of hues but changes hue, chroma, and luminance smoothly.

(Source code, png, hires.png, pdf)

../_images/endrainbow-3.png

(Source code, png, hires.png, pdf)

../_images/endrainbow-4.png

Consequently, the figure with the sunset palette also works reasonably well in grayscale or for colorblind viewers while the original palette is rather problematic.

../_images/fv3gfs-rainbow-gray.png ../_images/fv3gfs-sunset-gray.png ../_images/fv3gfs-rainbow-deutan.png ../_images/fv3gfs-sunset-deutan.png

Risk map: Influenza

The shaded map below was taken from the web site of the Robert Koch-Institut (Arbeitsgemeinschaft Influenza) and it shows the severity of influenza in Germany in week 8, 2019. The original color palette (left) is the classic rainbow ranging from “normal” (blue) to “strongly increased” (red). As all colors in the palette are very flashy and highly-saturated it is hard to grasp intuitively which areas are most affected by influenza. Also, the least interesting “normal” areas stand out as blue is the darkest color in the palette.

As an alternative, a proper multi-hue sequential_hcl("Purple-Yellow")(99) palette is used on the right. This has smooth gradients and the overall message can be grasped quickly, giving focus to the high-risk regions depicted with dark/colorful colors. However, the extremely sharp transitions between “normal” and “strongly increased” areas (e.g., in the North and the East) might indicate some overfitting in the underlying smoothing for the map.

../_images/influenza-rainbow.png ../_images/influenza-purpleyellow.png

Converting all colors to grayscale brings out even more clearly why the overall picture is so hard to grasp with the original palette: The gradients are discontinuous switching several times between bright and dark. Thus, it is hard to identify the high-risk regions while this is more natural and straightforward with the HCL-based sequential palette.

../_images/influenza-rainbow-gray.png ../_images/influenza-purpleyellow-gray.png

Emulating deuteranope vision emphasizes the same problems as the desaturated version above but shows even more problems with the original palette.

../_images/influenza-rainbow-deutan.png ../_images/influenza-purpleyellow-deutan.png

Showing changes in hue/chroma/luminance across the two palettes also highlights the discontinuity vs. smoothness of the two palettes.

(Source code, png, hires.png, pdf)

../_images/endrainbow-5.png

(Source code, png, hires.png, pdf)

../_images/endrainbow-6.png

References

[1]

H Brettel, F Viénot, and J D Mollon. Computerized simulation of color appearance for dichromats. Journal of the Optical Society of America A, 14:2647–2655, 1997. doi:10.1364/josaa.14.002647.

[2]

Fabio Crameri. Geodynamic diagnostics, scientific visualisation and \textit StagLab 3.0. Geoscientific Model Development, 11(6):2541–2562, 2018. doi:10.5194/gmd-11-2541-2018.

[3]

Mark A. Harrower and Cynthia A. Brewer. \textit ColorBrewer.org: an online tool for selecting color schemes for maps. The Cartographic Journal, 40:27–37, 2003. URL: http://ColorBrewer.org/.

[4]

Ed Hawkins, Doug McNeall, David Stephenson, Jonny Williams, and Dave Carlson. The end of the rainbow – an open letter to the climate science community. 2014. URL: http://www.climate-lab-book.ac.uk/2014/end-of-the-rainbow/.

[5]

Thomas Kneib. Mixed model-based inference in geoadditive hazard regression for interval-censored survival times. Computational Statistics & Data Analysis, 51:777–792, 2006. Figure 5 (left). doi:10.1016/j.csda.2006.06.019.

[6]

Thomas Lumley. \textit dichromat: Color Schemes for Dichromats. 2013. \textsf R package version 2.0-0. URL: https://CRAN.R-project.org/package=dichromat.

[7]

Gustavo M. Machado, Manuel M. Oliveira, and Leandro A. F. Fernandes. A physiologically-based model for simulation of color vision deficiency. IEEE Transactions on Visualization and Computer Graphics, 15(6):1291–1298, 2009. URL: http://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html, doi:10.1109/TVCG.2009.113.

[8]

P. S. Quinan, L. M. Padilla, S. H. Creem-Regehr, and M. Meyer. Examining implicit discretization in spectral schemes. In M. Gleicher, H. Leitte, and I. Viola, editors, Eurographics Conference on Visualization (EuroVis) 2019, volume 38, 3. John Wiley & Sons, 2019. URL: https://vdl.sci.utah.edu/publications/2019_eurovis_implicit-discretization/.

[9]

Karthik Ram and Hadley Wickham. \textit wesanderson: A Wes Anderson Palette Generator. 2018. \textsf R package version 0.3.6. URL: https://CRAN.R-project.org/package=wesanderson.

[10]

Reto Stauffer, Georg J. Mayr, Markus Dabernig, and Achim Zeileis. Somewhere over the rainbow: how to make effective use of colors in meteorological visualizations. Bulletin of the American Meteorological Society, 96(2):203–216, 2015. doi:10.1175/BAMS-D-13-00155.1.

[11]

F Viénot, H Brettel, and J D Mollon. Digital video colourmaps for checking the legibility of displays by dichromats. Color Research and Application, 24(4):243–252, 1999. doi:10.1002/(sici)1520-6378(199908)24:4<243::aid-col5>3.3.co;2-v.

[12]

F Viénot, H Brettel, L Ott, A B M'Barek, and J D Mollon. What do colour-blind people see? Nature, 376:127–128, 1995. doi:10.1038/376127a0.

[13]

Wikipedia. CIELAB color space — Wikipedia, the free encyclopedia. 2021. Accessed 2021-06-09. URL: https://en.wikipedia.org/wiki/CIELAB_color_space.

[14]

Leland Wilkinson. The Grammar of Graphics. Springer-Verlag, 2nd edition, 2005.

[15]

Achim Zeileis, Kurt Hornik, and Paul Murrell. Escaping RGBland: selecting colors for statistical graphics. Report 61, Department of Statistics and Mathematics, Wirtschaftsuniversität Wien, Research Report Series, November 2007. URL: http://epub.wu-wien.ac.at/.

[16]

CARTO. Cartocolors – data-driven color schemes. 2019. URL: https://carto.com/carto-colors/.