27
$\begingroup$

As announced in https://www.youtube.com/watch?v=xAoljeRJ3lU, Matplotlib changes the default colormap from jet to viridis.

However, I don't understand it pretty well. Maybe because I'm color blind?

The original colormap jet looks very strong, I can feel the contrast:

enter image description here

While the new colormap viridis lacks that contrast:

enter image description here

Can anyone please explain it simpler for me? I need the plot for my paper. And I need a good reason to convince my supervisor (and myself) that the viridis is a better one.

$\endgroup$
  • 2
    $\begingroup$ Note that Matlab has recently switched from jet to parula (as discussed in the linked video). $\endgroup$ – amoeba says Reinstate Monica Jul 12 '16 at 13:48
  • $\begingroup$ +1 to @amoeba comment. Since R2014b MATLAB uses the parula colour-map. One of the main reasons was that jet was rather uninformative for colour-blind male users and switching to parula was motivated by this. Male colour-blindness is commonly about 7-8% in quite a few north-European populations. $\endgroup$ – usεr11852 says Reinstate Monic Jul 12 '16 at 16:35
  • 1
    $\begingroup$ Use magma, plasma or inferno then... you are not forced to use the default, and IMHO the other three are "stronger". Viridis was chosen as default because "default must have green". If you want then in MATLAB you can get them here. Disclaimer: the FEX submission is mine. $\endgroup$ – Ander Biguri Jul 15 '16 at 13:04
  • 3
    $\begingroup$ We also built a tool that helps you to analyze the different colormaps w.r.t. perceptual uniformity, linearity of grayscale mapping, and suitability for color-blind viewers. See bids.github.io/colormap and github.com/matplotlib/viscm We have a branch in development for designing bi-directional colormaps. $\endgroup$ – Stefan van der Walt Oct 7 '16 at 18:27
33
$\begingroup$

See this video. You could also google it because there are a lot of (reasonable) jet-bashing everywhere.

Jet is very pleasing because it is flashy, colorful, and it does not require you to think about your color scale: even if you have just a few outliers, you still get "all the features" in your plot. You said it yourself: jet almost never lacks contrast.

However this comes at a very high price: jet literally shows things that do not exist. It creates contrast out of nowhere: just change your color scale a little bit in jet and you should see that the picture is change dramatically. Do the same thing in viridis, and you would merely have the impression that you are putting more or less light on the exact same thing.

If you don't like viridis, use the other colormaps that were discussed in the video above: they have the same nice properties, and they won't make your data lie. Also change the color scale: starting at 0, even if it is logical from a scientific point of view, may not be a good idea to represent these specific data (but change your colorbar to reflect that, e.g. "<25").

But again, see the video, there are a lot of examples in there as well as complete explanations.

$\endgroup$
  • 1
    $\begingroup$ Got it, you actually link back the video I posted. I watch it again. And when at start, it gives the example of Mona Lisa. I suddenly get it. jet high light the contrast that does not exist, e.g. the forehead of Mona Lisa. $\endgroup$ – cqcn1991 Jul 12 '16 at 12:02
  • 6
    $\begingroup$ Yes, exactly: typically jet over-emphasizes yellow and cyan. Depending on your color scale, you will "see" different things. In veridis-like colormaps, if you don't see something you used to see in jet then it means that the the thing you are looking for is negligible compared to the rest: this is the whole purpose of a colormap, to give our brain an estimate of the relative significance of each pixel. :) (and yes, you cited the video, but it really contains good examples and I was wondering I you already saw it or just cited it to present veridis) $\endgroup$ – JohnW Jul 12 '16 at 12:10
  • $\begingroup$ And there have been examples of papers chasing explanations of weird effects that were just artefacts of jet. I'll try to dig some. $\endgroup$ – Davidmh Jul 12 '16 at 19:48
  • $\begingroup$ I also have to add that the performance of virdis varies according to differnt screens. I have an old laptop and a new desktop hackintosh. The desktop hackintosh's virdis looks much better and clearer than the laptop. $\endgroup$ – cqcn1991 Jul 13 '16 at 0:58
  • 2
    $\begingroup$ So, there is this example. Unfortunately, the original reference is in the blog abandonmatlab, that is now private. All the blogs that I could find cite the blog, but not the paper. If anyone finds it, I will be very glad. $\endgroup$ – Davidmh Jul 13 '16 at 10:58
11
$\begingroup$

You need the plot because you need to show data and you need a colormap because you know that the color you show will not be seen equally by all persons: any color is an interpretation through our visual perception.

Indeed, colors are subjective in the sense that they are interpreted by the brain (in the sense that a spectrum is transformed into a neural activity) into different levels of valence (or value) as a function of the colorbar given next to it. Your eyes will make a constant set of saccades to match the plot with the bar.

JET is to be banned because it is perceptually ambiguous. One first feature of colors in visual perception is its value, that is the total brightness, that acts as the most direct feature. However, this value is non-monotonic in JET, such that ONE value in brightness may induce different values in perception. This is in particular true for the blueiash - yellowish tone (and that most of the time those that correspond to zero values) which artificially "pop up" from an image. Check such curves on : brightness of different colormaps

Viridis (among other alternatives) is made to avoid that problem. You may read this full description for this choice, and how to adapt your colormap to the category of data to plot.

This should convince your supervisor.

$\endgroup$
7
$\begingroup$

The issue with using any kind of color scale to visually represent ordinal data is that of luminance monotonicity: that is to say, if you have data that satisfy some kind of ordering relationship, that relationship should be reflected not just by changes in hue, but by luminance. The problem with the "jet" color mapping is that the highest point in the mapping (corresponding to larger values) is given a red color, the middle range is given a yellow-green color, and the lowest is blue--but if we look at the perceived "brightness" (i.e., luminance) of those colors, it is clear that this mapping is not monotone. The other color mapping in your question fixes this defect.

The reason for this property should be obvious, not the least of which is the fact that if such figures are reproduced in grayscale, interpretability is not lost.

$\endgroup$
6
$\begingroup$

There's several nice answers here already, but I think it's still pertinent to add another viewpoint, from the excellent paper

Good Colour Maps: How to Design Them. Peter Kovesi. arXiv:1509.03700 (2015). Software available here.

which lays out in a very clear fashion the principles of colour-map design, and provides a really nice tool to analyze them for perceptual uniformity:

enter image description here

This 'washboard' plot has a steady ramp from zero to one going left to right along the bottom, and the top of the plot has a sinusoidal modulation of uniform amplitude. For a properly-designed color map, all of the fringes at the top should show identical, or at least similar, contrast. However, when you put jet to the test, it is immediately obvious that this is not the case:

enter image description here

In other words, there are a ton of fringes, in the red and particularly the green stretches of jet, that get completely nuked out and become completely invisible, because the colour map simply does not have any contrast there. When you apply this to your data, the contrast in those regions will go the same way as the fringes. Similarly, the sharp contrasts along the bottom, on what should be a smooth linear scale, represent places where the map is introducing features that are not really present in the data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.