The rainbow is dead…long live the rainbow! – Perceptual palettes, part 1


This is the first  post in a series on the rainbow and similar color palettes. My goal is to demonstrate it is not a good idea to use these palettes to display scientific data, and then answer these two questions: (1) is there anything we can do to “fix” the rainbow, and (2) if not, can we design a new one from scratch.

The rainbow is dead…some examples

In a previous post I showed a pseudo-3D rendering of my left hand x-ray using intensity (which is a measure of bone thickness) as the elevation. I mapped the rendering to both grayscale and rainbow color palettes, and here I reproduced the two images side by side:

I used this example to argue (briefly) that the rainbow obscures some details and confuses images by introducing artifacts. Notice that in this case it clearly reduces the effectiveness of the pseudo-3D rendering in general. It also introduces inversions in the perception of elevation. The thick part in the head of the radius bone, indicated by the arrow, looks like a depression, whereas it is clearly (and correctly) a high in the grayscale version.

In some case I cited a note [1] by the IBM Research Centre, which highlight how the rainbow color palette creates these perceptual artifacts (particularly the first two examples). I introduced the notion that rainbow is very confusing for people with color deficiencies (up to 8% in caucasian men), referencing an excellent simulation of these confusing effects shown in Fig.1 af an article [2] in the American Geophysical Union’s EOS publication. I also posted an example of my own in A rainbow for everyone.

In the figure below, from [3], I show a final, striking example. The image has three panels with the same bust colored using grayscale, heated body, and rainbow-like palette. Notice that not only is the latter confusing but also unpleasant and unnatural.

I wanted to understand a bit more the reason why is it so, and answer to the question: ‘is there anything we can do about it?’  Today’s post will focus on that. So, why does the rainbow looks and feels unpleasant and unnatural? Here’s the first clue. I converted the three panels above to intensity and then mapped them all to grayscale (the same result would be achieved in Photoshop or other software with a conversion to grayscale). The result is below: it tells me that it is the intensity information in the rainbow sequence of hues that is “not right”.

And yet the rainbow color palette is the most commonly used of all, across all scientific disciplines. Borland and Taylor in [4] quantify how widespread the use of rainbow is and point out that it is the default in the greatest majority of software packages. They also note that the medical and biomedical communities have caught up with this idea more rapidly and that different palettes are used by practitioners in those disciplines. A great example can be found in [5], where the authors argue that using rainbow in artery visualization has a negative impact on task performance, and may even cause a higher rate of heart disease misdiagnosis! Some alternative palettes that are preferable to the rainbow are recommended in those papers. From reading what I reported so far, and from several other papers and notes on the subject, I am convinced that the rainbow is not right. Then I asked myself: can I do anything to demonstrate it further, perhaps quantify it? I think I can answer this question, and will do it in the next section.

The visible (natural) spectrum in RGB and CIE L*a*b* color spaces

First I created a natural spectrum palette using the CIE 1931 modified by Judd and Vos (found here). In this palette the XYZ triplets represent colors sampled at a constant interval of 5 nanometer in the wavelength range  360-830. I reduced the palette to approximately the visible range (400-700 nm) and then converted the XYZ triplets to RGB values using this submissions (Spectral and xyz color functions) from the Matlab File Exchange. In the left panel of the figure below, I used the Great Pyramid of Giza as a test surface for this palette. The colorbar indicates elevation, which is in feet (easier to code as the total pyramid height in meters was a non integer number). I used the pyramid to assess how perceptual the natural spectrum palette is: because pyramids have monotonically increasing elevation there should be no discontinuities in the surface if the palette is perceptually monotonic. Instead, there are at least two major discontinuities visible in the pyramid (the yellow, and the blue) and they bound an area of nearly constant color (green). These are obviously artifacts and because the pyramid is a perfectly flat surface we know they are caused by the palette.

In addition to the above I tried a more quantitative assessment: I converted each of the 256 RGB triplets to CIE L*a*b* values to examine the behaviour of the lightness L*, the quantitative axis of CIE L*a*b* space. Since this color space was specifically designed to accurately map color perception it seemed an obvious test. In the right panel in the figure above I plotted L* against pyramid elevation so that the plot and the pyramid image can be easily be compared back and forth; to facilitate the task I also colored the L* plot line accordingly. To me this plot elegantly explains the artifacts in the pyramid by showing where lightness changes are non monotonic.  For example L* it increases from black to purple, then flattens and drops from purple to blue, then it increases again through light blue and cyan, then it plateaus at the green, and so on. On top of that, the curve gradient changes in a number of places, indicating a non-uniform perceptual distance between samples. This is troublesome if the palette is used to map elevation because it will interfere with the correct perception of relief as we have seen with the pyramid. The effect would be even more confusing if shading is added. What happens then with surfaces that are not as regular as the pyramid? We may not be able to distinguish real edges from artifacts, therefore our ability to interpret is hindered. The takeaway is that yes the visible spectrum is a natural progression of colors in terms of wavelengths, but it is definitely a poor choice for surface mapping and visualization.

Matlab code

I shared in the previous post the code to create the pseudo-3D hand x-ray displays. To create the pyramid and L* plot to test your own palette you can use the code in the box below. In addition to the code snippet you will need to download these two submissions from the Matlab File Exchange: Colorspace transformations  and Colormapline from the Matlab File Exchange. If you want to use the natural spectrum please download my RGB triplets and import them into Matlab.

%% This cell creates the Great Pyramid of Khufu in Giza
% using the original(pre-erosion) dimensions of 755x755x482 feet 
% (I am using imperial measurements as they are round numbers 
% - metrics measurements are not)
for i = 1:241
PY3= flipud(PY1);
clear i test test1 PY PY1 PY2 PY3 PY4 temp;
%%  This cell plots the pyramid with SURF (interpolated color) 
axis off;
grid off;
% set(fig1,'Position',[720 400 950 708]);
% set(fig1,'OuterPosition',[716 396 958 790]);
title('Natural spectrum','Color','k','FontSize',12,'FontWeight','demi');
%%  This cell creates L* plot for natural spectrum
title ('L* plot for natural spectrum colormap','Color','k','FontSize',12);

If you have a Matlab figure already open and want to use the code above with the color palette for that figure, add this command at the top:

mycmap = colormap;

and replace spectrum with mycmap in the rest of the code.

In the next post I will look at the rainbow as it is seen by people with color vision deficiencies, then I will show what I have done to fix it. Stay tuned!

Related posts (MyCarta)

The rainbow is dead…long live the rainbow! – the full series

What is a colour space? reblogged from Colour Chat

Color Use Guidelines for Mapping and Visualization

A rainbow for everyone

Is Indigo really a colour of the rainbow?

Why is the hue circle circular at all?

A good divergent color palette for Matlab

Related topics (external)

Color in scientific visualization

The dangers of default disdain

Color tools

How to avoid equidistant HSV colors

Non-uniform gradient creator

Colormap tool

Color Oracle – color vision deficiency simulation – stand alone (Window, Mac and Linux)

Dichromacy –  color vision deficiency simulation – open source plugin for ImageJ

Vischeck – color vision deficiency simulation – plugin for ImageJ and Photoshop (Windows and Linux)

For teachers

NASA’s teaching resources for grades 6-9: What’s the Frequency, Roy G. Biv?


[1] Rogowitz, B.E., and Treinish, L.A., – Why Should Engineers and Scientists Be Worried About Color?

[2] Light, A. and Bartlein, P.J. (2004) – The end of the rainbow? Color schemes for improved data graphics – EOS Transactions of the American Geophysical Union 85 (40) – Reprint of Article with Replies

[3] Color for the Sciences, Jan J. Koenderink, 2010 MIT Press

[4] Borland, D. and Taylor, R. M. II (2007) – Rainbow Color Map (Still) Considered Harmful – Computer Graphics and Applications, Vol. 27, No. 2 (IEEE)

[5] Borkin, M.A.,  et al. (2011) – Evaluation of Artery Visualizations for Heart Disease Diagnosis – Transactions on Visualization and Computer Graphics, Vol. 17, No. 12 (IEEE)

33 thoughts on “The rainbow is dead…long live the rainbow! – Perceptual palettes, part 1

  1. Pingback: CT scan colormaps | chronoclasm

  2. Pingback: New Matlab isoluminant colormap for azimuth data | MyCarta

  3. Pingback: What your brain does with colours when you are not “looking” – part 2 | MyCarta

  4. Pingback: New rainbow colormap: sawthoot-shaped lightness profile | MyCarta

  5. Pingback: The end of the rainbow | Climate Lab Book

  6. Pingback: End of the rainbow | Better Figures

  7. Pingback: The end of the rainbow … an open letter to the climate science community @ Weather and Climate Discussion

  8. I think your pages about the rainbow are very interesting and I enjoyed reading them and getting some good links.
    However, I think using your left hand x-ray image or the bust as a “proof” that using standard rainbow color palettes for scientific data visualisation are bad, is not a completely valid conclusion. The major point missed here is, IMHO, that we are used to a specific shading/coloring of these images and it confuses us if we do not get it. In both cases our brains are trained to interpret the x-ray intensity or the shadows on the bust to recognize the shape of a three dimensional object. If the colorscale applied e.g. to the bust has no continuous light-to-dark interpolation, the “in-brain 3d reconstruction” fails. However, imagine someone tells you the rainbow-image of the bust displays “a bust with the color indicating the measured temperature using a thermo-camera”. If you’d have seen thermal images using similar colors before you would not be confused.
    A further step would be to argue that colorscales – even “bad” rainbows – are especially useful if there is no underlying geometry (bust, hand, world map) or similar secondary data. In these cases rainbow colorscales can display more information than simple grayscale.
    Also, I am not sure if you mentioned this somewhere, these perceptual breaks in the colorscale due to lightness changes may be used on purpose to create an effect similar to contour plots (e.g. the bright bands colormap in mathematica).

    • Hi Gluon

      I understand of your comments, and some of them may be valid, but just to a point. I’ve heard the argument that with consistent use, our brain accommodates for the non-perceptual artifacts of the rainbow and that many come to expect it. This may be true, and
      may be desireable by some, particularly when using a single map.

      However, take a look at one of my more recent posts in the same series here: in the second portion of the article, and Figures 4 to 6, I show a map in which I display some geophysical data and then use the gradient to simulate relief. The effect breaks down because of the banding in the standard rainbow colormaps (Figures 5 and 6). This does not happen in Figure 4.

      Moreover, and to me worse even, these standard rainbows are not good for people with color vision deficiency (improperly called color blindness). Look at the last two figures in the same article as an example. If a person with Deuteranopia (the most common form of color vision deficiency) were to look at either of those maps it for the first time they would most likely be very confused by them, having a hard time figuring out what is high and what is low, even with the aid of the colorbar (let alone without it). By using those colormaps then we’d confuse 8 percent our audience (assuming the distribution of people with color vision deficiency in geoscience is the same as in the general population).

      By the way, an argument against the idea that training the brain to use rainbow: Borkin et al. (Evaluation of artery visualizations for heart disease
      ), argue that using rainbow in artery visualization has a negative impact on task performance, and may cause more heart disease misdiagnoses. These are highly trained physicians that know very well how arteries should look like in images, and yet they make more mistakes when viewing them displayed with rainbow as opposed to, say, grayscale.

      I do not have much expereince with thermal cameras, but heated body seems to me a fine alternative to rainbow.
      I definitely agree that rainbow colorscales can display more information than grayscale, or even one of the more perceptual rainbows I and others developed. But this to me is in fact another good reason to NOT use a standard rainbow, because the user has no control on where each of several areas of high contrast are located in the colormap, so a lot of effort is wasted to fit those regions of artificially high contrast to the portion of data of interest. I’ve written about it in a recent post.

      Finally, yes, the bands of nearly constant colour simulate filled contours, but I am not sure why I would want the ranges of those filled contours be dependent on the colormap lightness profile, as opposed to using a proper filled contour option.

  9. Pingback: Color schemes and perception: If L*-linearity does not imply perceptual intensity linearity, then what is the best metric of perceptual intensity? [closed] | Question and Answer

  10. Pingback: Histogram Equalization in Python and matplotlib – Geophysics Labs

Leave a Reply