Python/Matplotlib - Colorbar Range and Display Values Python/Matplotlib - Colorbar Range and Display Values python python

Python/Matplotlib - Colorbar Range and Display Values


If I understand correctly what you want, I think this should do it:

import numpy as npimport matplotlib.pyplot as pltxi = np.array([0., 0.5, 1.0])yi = np.array([0., 0.5, 1.0])zi = np.array([[0., 1.0, 2.0],               [0., 1.0, 2.0],               [-0.1, 1.0, 2.0]])v = np.linspace(-.1, 2.0, 15, endpoint=True)plt.contour(xi, yi, zi, v, linewidths=0.5, colors='k')plt.contourf(xi, yi, zi, v, cmap=plt.cm.jet)x = plt.colorbar(ticks=v)print xplt.show()

enter image description here