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. The example with the hand is nice. In that example, the information is initially contained in the lightness variation. When we convert to the rainbow there will be still variances in lightness, but no longer will these be correlated with the actual information (I guess they will be random; some hues will be lighter than others depending upon various factors such as colour management). There will be hue variation and essentially the lightness information is converted to hue information. But people won’t interpret it in the same way, I agree. And in this example, the use of the rainbow colours adds nothing; in fact, it makes it worse. However, there may be cases where there is a good reason for using the rainbow colours.

    • Hi Stephen
      Thank you for reblogging my post and for your comments. I really like your take on the hand image – in fact your explanation adds quite nicely to the example. I am curious to know if you have yet seen a good example where using the rainbow was useful, and could share it. After reading your comments I gave it a thought and concluded that perhaps the rainbow could be used with categorical data. Then it occurred to me we’d be ignoring the implication for people with color vision deficiencies, who would confuse data in the green vs. red classes etcetera. The rainbow I will introduce at the end of this series does not have any of these problems.

  2. Pingback: The rainbow is dead…long live the rainbow! – Part 2: a rainbow puzzle «

  3. Pingback: The rainbow is dead…long live the rainbow! – series outline «

  4. Matteo, so would I be correct in assuming that the false structures that we see in the rainbow palette are caused by inflection points in the brightness? I always assumed that the lineations we pick out are caused by our flawed color perception but it looks from your examples that they are occurring where brightness changes slope.


    • Hi Steve

      This is a great question, and I am really glad you brought it up. This is not necessarily the best answer, or all the answer, but I’ve thought about it a lot while researching this topic and I would say it is both inflections and flawed color perception. I think that the latter is in fact responsible for the former. But hold the thought: I think the question is worth an extended answer and I will do it with an extra mini-post to come shortly. It also fits well with some more exotic experiments I did, which where only in part successful, but interesting, and now I have an excuse to show the results.

  5. Pingback: The rainbow is dead…long live the rainbow! – series outline « MyCarta

  6. Pingback: A good divergent color palette for Matlab « MyCarta

  7. Pingback: Better Palettes « MyCarta

  8. Pingback: The rainbow is dead…long live the rainbow! – Part 3 « MyCarta

  9. Pingback: The rainbow is dead…long live the rainbow! – Part 4 – CIE Lab heated body « MyCarta

  10. Pingback: The rainbow is dead…long live the rainbow! – Part 5 – CIE Lab linear L* rainbow « MyCarta

  11. Pingback: Comparing color palettes | MyCarta

  12. Pingback: Perceptual rainbow palette – the method | MyCarta

    • Hi Nikita
      Thanks for the feedback.
      The method is explained in full in this post.
      If you need a reference, I introduced the cube law Lightness palette in How to assess a colourmap, an essay in the book 52 Things You Should Know About Geophysics and then presented it in a talk at the 2012 convention of the Canadian Society of Exploration Geophysicists. You can find the abstract at this link.
      The cube law Lightness palette was also used in a Marek Kultys’ excellent tutorial Visual Alpha-Beta-Gamma: Rudiments of Visual Design for Data Explorers, published on Parsons Journal for information mapping, Volume V, Issue 1.

      • Matteo, big thanks!
        Yes, I need reference, “How to assess a colourmap” it’s what I was looking for. If you do not mind, I refer to your work.

        I’m writing a diploma work in “Usability” discipline, where one chapter contains thoughts about the best color palletes for the “User Click Heat Maps”, and I think this articles and rules are applicable for it. What do you think about such case?

      • Hi NIkita
        You are welcome to cite my work, and to use/peruse/modify these palettes if you need to. Wether the palette is appropriate or not depends a bit on the data and its distribution. The cube law Lightness palette is good, but if you are dealing with data with very large value range, perhaps the Linear monotonically increasing lightness palette may be better as it has larger total Lightness contrast, and more hues. If you need a reference you can use in combination the article where the original palette is presented, and the blog post where I show how I modified it. Good luck with your diploma paper.

      • Hi Nikita

        Heated body is a good choice. I talked about it here.
        I also agree there are lots of alternatives. One of the best paper on this topic – and in the field of colormaps in general – is Bernice Rogowits and Alan Kalvin’s Which Blair Project
        If you are going to run comparisons I’d be curious to see them. Keep me posted.

Leave a Reply