Perceptual rainbow palette – the goodies

Perceptual rainbow palette – Matlab function and ASCII files

In my last post I introduced cubeYF, my custom-made perceptual lightness rainbow palette. As promised there, I am sharing the palette  with today’s post. For the Matlab users, cube YF, along with the other palettes I introduced in the series, is part of the Matlab File Exchange submission Perceptually improved colormaps.

For the non-Matlab users, please download the cubeYF here (RGB, 256 samples). You may also be interested in cube1, which has a slightly superior visual hue contrast, due to the addition of a red-like color at the high lightness end but at the cost of a modest deviation from 100% perceptual. I used cube 1 in my Visualization tips for geoscientists series.

Perceptual rainbow palette – preformatted in various software formats

The palettes are also formatted for a number of platforms and software products: Geosoft, Hampson-Russell, SMT Kingdom, Landmark Decision Space Geoscience, Madagascar, OpendTect, Python/Matplotlib, Schlumberger Petrel, Seisware, Golden Software Surfer, Paradigm Voxelgeo. Please download them from my Color Palettes page and follow instructions therein.

Another example

In Comparing color palettes I used a map of South America [1] to compare a linear lightness palette to some common rainbow palettes using  grayscale as a perceptual benchmark. Below, I am doing the same for the cubeYF colormap.


Comparison of South America maps using, from left to right: ROYGBIV (from this post) , classic rainbow, cubeYF, and grayscale

Again, there is little doubt in my mind that cubeYF does a superior job compared to the other two rainbow palettes as it is free of artefacts [2] and more similar to grayscale  (with the additional benefit of color).

The ROYGBIV and cubeYF map have been included in Marek Kultys’ excellent tutorial Visual Alpha-Beta-Gamma: Rudiments of Visual Design for Data Explorers, recently published  on Parsons Journal for information mapping, Volume V, Issue 1.

An online palette testing tool

Both cubeYF and cube1 feature in the colormap evaluation tool by the Data Analysis and Assessment Center at the Engineer Research and Development Center. If you want to quickly evaluate a number of palettes, this is the right tool. The tool has a collection of many palettes, organized by categories, which can be used on 5 different test image, and examined in terms of RGB components and human perception. Below here is an example using cube YF.


An idea for a palette’s mood test

A few weeks ago, thanks to Matt Hall (@kwinkunks on twitter),  I discovered Colour monitor, a great online tool by Richard Weeler (@Zephyris on twitter). You supply an image; Colour monitor analyses its colors in terms of hue, saturation and luminance and produces a graphical representation of the image’s mood [3]. I thought, what a wonderful idea!

Then I wondered: what if I used this to tell me something about a color palette’s mood? The circular histogram of colors reminded me of the Harmonic templates [4] on the hue wheel from this paper And so I created fat colorbars using the three  palettes I used in the last post, saved them as images, and run the monitor with them. Here below are the results for Matlab jet, Industry Spectrum, and cubeYF. Looking at these palettes in terms of harmony I would say that jet is not very harmonic (too large a portion of the hue circle; the T template, which is the largest, spans 180 degrees), and that the spectrum is terrible.

CubeYF is also exceeding a bit 180 degrees, but looks very close to a T template rotated by 180 degrees (rotations are allowed). So perhaps I could trim it a bit? But to me it looks a lot nicer and gives me a vibe of really good mood, and reminds me of one of those beautiful central american headdresses, like Moctezuma’s crown.


Jet mood


Spectrum mood


cubeYF mood


[1] Created with data from the Global Land One-km Base Elevation Project at the National Geophysical Data Center.

[2] Looking at the intensity of the colorbars may help in the assessment: the third and fourth colorbars are very similar and both look perceptually linear, whereas the first and second do not.

[3] Quoted from Richard’s blog post: “… in the middle is a circular histogram of the colours (spectral shades) in the image, and gives an idea of how much of each colour there is. Up the left is a histogram of image brightness (lightness of colour), and up the right is a histogram of colour saturation (vibrancy)”.

[4] Quoted from the paper’s abstract: “Harmonic colors are sets of colors that are aesthetically pleasing in terms of human visual perception. If you are interested in this idea there is a set of slides and a video on the author’s website

Related posts

20 responses to “Perceptual rainbow palette – the goodies

  1. Pingback: The rainbow is dead…long live the rainbow! – series outline | MyCarta·

  2. Is it possible to cast CubeYF to RGB for use in software that can only handle palettes defined with by the RGB model?

  3. A fellow member of the Matlab Users and Integrators group on LinkedIn asked:”..are perfectly balanced (color length equal across spectrum) possible or ideal?”

    To which I replied:”If I understand your question correctly, you want to know if it is possible to make color palettes where perceptual distance between samples does varies regularly – in other words where Euclidean distance between data values correspond to Euclidean distance between hues. If that’s the case, the quick answer is yes. If you accept that CIELab color space is a good approximation of human perception, then you all you need is a color palette with linear Lightness like the one in this post:
    To me CIELab is a good starting point. By using it, we certainly get in ballpark. There are however more recent color spaces that are considered even better approximations of human vision.”

    See for example the discussion in chapter 1.3 of Computational Colour Science using MATLAB (Wiley), by Stephen Westland and Caterina Ripamonti

  4. Pingback: Color palettes for seismic structure maps and attributes | MyCarta·

  5. Hi, I’m a bit confused by the RGB download of CubeYF. I’m trying to import the color ramp into ArcGIS, which takes RGB values. In the spreadsheet, is column 1 = R, column 2 = G, column 3 = B ? And for the color values in each column, they are decimal values, does this mean 0.443 = 43.3 when entering into RGB? RGB is typically whole number numbers 111,123,233. Really love the CubeYF and would love to use it (crediting you of course!)

    • Hi Tim

      Good question. I should clarify it in the post and page. You understand correctly that the three columns are column 1 = R, column 2 = G, column 3 = B. But the values are not in the range 0-255 as some programs require; they are in the range 0-1 as some other programs require. To get from the values in the file to the values you need, just multiply by 255 and round the values to integer.

  6. Pingback: NASA Worldview satellite image browser adopts MyCarta perceptual rainbow | MyCarta·

  7. Hi Matteo,
    thanks for your work in this interesting yet sometimes underrated area.

    I’m using your colormap to plot spectrograms of audio signals but I have the impression the results are somehow worse than what I was obtaining with the MATLAB ‘hot’ colormap. After reading your article I think they’re worse only in the way that my perception was previously tricked by the ‘hot’ colormap, but in one of your previous posts that very colormap is described as a decent one (much better than ‘jet’, for example), so I can’t understand why my perception seems to be that different 🙂

    That’s why I wanted to ask you a question: do you think your colormap is suitable with any kind of dataset, no matter their values?

    • Hi Giuliano

      Thanks for your comments.

      The shortest and more generic answer to your last question is no, I don’t think the perceptual colormap I shared are suitable with any kind of dataset. One example: the cube law rainbow (CubeYF) may not work well for divergent data (positive and negative values, where the zero is significant) where positive and negative amplitudes have equal importance. That is because the ramp of the cube law changes on either side of the central sample.

      In the specific case of your spectrograms, it would be difficult without looking at some examples. Would you be able to share them?

      If you aren’t, here are some thoughts: I would definitely favor a colormap with perceptual lightness profile. you are right that your perception was calibrated on the hot colormap, but I think it may be more complicated than that. The hot colormap has some artifacts but also has Lightness values varying between L=0 and L=100, providing the largest possible contrast. Conversely, the CubeYF has lightness values varying between about L=30 and L=90. The choice was a good compromise between personal taste (I like pastel hues), and the need for a good contrast range. I used figure 8 in The “Which Blair Project: A Quick Visual Method for Evaluating Perceptual Color Maps” (there is a copy of the paper here). The figure shows the effectiveness of a colormap decreases logarithmically with L contrast, so 60% is still good, but is not optimal if what you’re after IS contrast.

      If I were you I would try to use my modified heated body, or the linear L rainbow. Please do let me know how those compare, it would be really valuable feedback.

  8. Hi Matteo,
    thanks for your quick and very informative reply.
    I must admit that I hadn’t really gone deep in the construction process of your colormap and thus, I missed some details like the reduced contrast (which in my case is beneficial).

    I will produce some figures with some different colormaps (so far I’ve tried MATLAB’s ‘jet’ and ‘hot’ as well as yours and I’ll compare them with the two modified version you suggested) and share them.

    I’ll keep you posted!

    Thanks again 😉

  9. Pingback: Convert color palettes to Python Matplotlib colormaps | MyCarta·

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

  11. Hi Matteo,

    Thank you for your work on this, I really like the LinearL Rainbow scale and am finding it useful for visualizing seismic attributes.

    I am interested in finding a color scale for seismic data that would have a meaningful lightness profile. It would make sense for this to have a V shape–high lightness for high amplitudes, whether positive or negative, and low lightness for the middle.

    We commonly use white-grey-black or red-white-blue. White-grey black at least is linear, but it isn’t the v-profile I think might work best, and it misses out on using color for more detail. Red-white-blue puts the lightest color at zero amplitude–it is useful for seeing more amplitude contrast than white-grey-black, but it also doesn’t fit my v-shaped ideal.

    The ideal for me might be something like Petrel’s default color scale, but with black in the middle.

    Any thoughts on this?

    • Hi Will

      great to hear you find the LinearL useful. I use it with a lot of my attributes, including in Petrel; I particularly like it for impedance.

      As for divergent colormaps for amplitude, I am currently working on both v-shaped ones and enhanced gray scales. I am going to either post about them or submit a short note for the CSEG Recorder; I’ll keep readers posted here on the blog in any case.

      For now, take a look at Moreland’d divergent colormaps available on his site; although they still have the high lightness values in the middle, they do not have the colour mach band effet of the classic seismic red-white-blue, which in my opinion is what destrys a lot of the low amplitude details.

      If you would like black to emphasize the zero crossing, you could add a zero contour on top of the colour display (this is Steve Lynch’s idea, thanks Steve!); if you used a transition to black, the overall display would end up really dark, giving the false impression that small amplitudes dominate (as a thought experiment, try and imagine these images, which have a middle-to-dark gray in the middle, as even darker).

      • Matteo,
        Thanks for your response. I see your point that having black in the middle can make image look very dark, although my focus is on seeing continuous high or low amplitudes (with linear L for the middle amplitudes), not on seeing the zero crossings. I’ve been playing with color scales and continue to be amazed how changing them can reveal different patterns in the data–looking forward to seeing the ones you’ve been working on!

  12. Matteo,

    your articles about the pitfalls of rainbow colorbars are enlightening. The example of the Giza pyramid and L* plot is very simple and very effective!
    When inspecting subsurface models (e.g. velocity) or maps (e.g. elevation map or Bouguer anomaly) the risk of being biased by artifacts due to gradient change in the L* plot is undeniable

    What are your thoughts about equalized colorbars, such as in Geosoft ?( Apart from the evident limitation of being data-dependent, for sure they improve the look and feel of the map.
    On the other hand, are they improving at the same time the “truthfulness” of the perception or are making it even worse?

    • Ciao Mattia

      Thanks for the positive feedback; and great question! Although I do know some of the Geosoft colourmaps, I do not have access to the software. I don’t mind the idea of histogram equalization because it definitely increases the overall contrast of the data, without clipping. However, it is a global contrast improvement. So, for a non perceptual colourmap such as the rainbow, this would not change the fact that different portions of it have different gradients. To get the kind of equalization that will render the colourmap more perceptual you’d want to use Peter Kovesi’s equalization (based on Pizer’s method) described in here. Peter has a Matlab function, equalisecolourmap.m, which you can download from here together with a whole bunch of other colour tools. He’s also created a Julia package. If you like Python, I’ve made a very similar tool, which you can find here. Let me know if you end up trying either.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s