import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, np.pi*4, 10) y = np.linspace(0, np.pi*4, 10) xx, yy = np.meshgrid(x, y) v = np.sin(xx) + np.cos(yy) plt.imshow(v, cmap=plt.cm.Blues, vmin=-1.5, vmax=1.5, extent=[x.min(), x.max(), y.min(), y.max()]) cbar = plt.colorbar(aspect=50, pad=0.08, orientation='horizontal', shrink=0.6, extend='both') plt.colorbar()