import numpy as NP
from matplotlib import pyplot as PLT
A = NP.random.random_integers(0, 10, 100).reshape(10, 10)
fig = PLT.figure()
ax1 = fig.add_subplot(111)
cax = ax1.imshow(A, interpolation='nearest')
cbar = fig.colorbar(cax, ticks=[0, 5, 10])
cbar.ax.set_yticklabels(['lo', 'med', 'hi'])
PLT.show()
How do I set a matplotlib colorbar extents?