I recently started to step out my comfort zone and learn Python throughoutly. While playing with matplotlib module, I noticed the upcoming chances in matplotlib 2.0 regarding default styles. The new default color map will be "viridis" instead of "jet". The presentation by Nathaniel Smith and Stefan van der Walt are very helpful and informative.
This amazing talk explained the decision procedures to choose "viridis" over "jet" based on the color theory. The designers considered the following principles for a 'good' color map:
The last four principels are very tricky and they have done a great job implementing them. The two color maps are compared here:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
nrows = 2
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))
cmap_list=['jet','viridis']
def plot_color_gradients(cmap_list, nrows):
fig, axes = plt.subplots(nrows=nrows)
fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99)
for i in [0,1]:
axes[i].imshow(gradient, aspect='auto', cmap = cmap_list[i])
pos = list(axes[i].get_position().bounds)
x_text = pos[0] - 0.01
y_text = pos[1] + pos[3]/2.
fig.text(x_text, y_text, cmap_list[i], va='center', ha='right', fontsize=10)
# Turn off *all* ticks & spines, not just the ones with colormaps.
for ax in axes:
ax.set_axis_off()
plot_color_gradients(cmap_list, nrows)
plt.show()
Written on August 17, 2016