April 2018
Beginner to intermediate
300 pages
7h 34m
English
Colormaps map numerical values to a range of colors.
Since Matplotlib 2.0, the default colormap has been changed from 'jet', which spans the visible light spectrum from red to blue, to 'viridis', which is a perceptually uniform continuum from yellow to blue. This makes it more intuitive to perceive continuous values:
import numpy as npimport matplotlib.pyplot as pltN = M = 200X, Y = np.ogrid[0:20:N*1j, 0:20:M*10]data = np.sin(np.pi * X*2 / 20) * np.cos(np.pi * Y*2 / 20)fig, (ax2, ax1) = plt.subplots(1, 2, figsize=(7, 3)) # cmap=viridis by defaultim = ax1.imshow(data, extent=[0, 200, 0, 200])ax1.set_title("v2.0: 'viridis'")fig.colorbar(im, ax=ax1, shrink=0.85)im2 = ax2.imshow(data, extent=[0, 200, 0, 200], cmap='jet')fig.colorbar(im2, ...Read now
Unlock full access