matplotlib Colormaps Perceptually uniform colormaps


The original default colourmap of MATLAB (replaced in version R2014b) called jet is ubiquitous due to its high contrast and familiarity (and was the default of matplotlib for compatibility reasons). Despite its popularity, traditional colormaps often have deficiencies when it comes to representing data accurately. The percieved change in these colormaps does not correspond to changes in data; and a conversion of the colormap to greyscale (by, for instance, printing a figure using a black-and-white printer) might cause loss of information.

Perceptually uniform colormaps have been introduced to make data visualization as accurate and accessible as possible. Matplotlib introduced four new, perceptually uniform colormaps in version 1.5, with one of them (named viridis) to be the default from version 2.0. These four colormaps (viridis, inferno, plasma and magma) are all optimal from the point of view of perception, and these should be used for data visualization by default unless there are very good reasons not to do so. These colormaps introduce as little bias as possible (by not creating features where there aren't any to begin with), and they are suitable for an audience with reduced color perception.

As an example for visually distorting data, consider the following two top-view plots of pyramid-like objects:

two pyramid-like objects from top

Which one of the two is a proper pyramid? The answer is of course that both of them are, but this is far from obvious from the plot using the jet colormap:

3d view of the pyramids with the two colormaps, jet vs viridis

This feature is at the core of perceptual uniformity.

This example is a derived from the work made originally by Matteo Niccoli: