Turbo, Parula and Mathematica colormaps for Matplotlib

There are some relevant—and beautiful—colormaps (hereafter cmaps) which are not available built-in in Matplotlib, namely the following ones:

I really enjoy these cmaps, so I incorporated them into the nmmn package for convenient usage within Python when using Matplotlib routines for plotting images.

In order to use these cmaps in your work, it is really easy:

1. Install the nmmn package

Using the following command in the terminal

pip install nmmn

2. Once nmmn is installed, choose your preferred cmap.

import nmmn.plots
wolfram=nmmn.plots.wolframcmap() # for Mathematica's cmap
parula=nmmn.plots.parulacmap() # for MATLAB's cmap
turbo=nmmn.plots.turbocmap() # Turbo

3. Use them to plot an image

pcolormesh(x, y, z, cmap=turbo, vmin=z_min, vmax=z_max)
title("Turbo")
colorbar()
An example of using the Turbo colormap to plot an image in matplotlib.

A Jupyter notebook illustrating and comparing the result of plotting different images with these cmaps is available. This notebook generates the comparison below.

Author: Rodrigo Nemmen

Professor of Astrophysics, Universidade de Sao Paulo

Leave a comment