Top label for matplotlib colorbars Top label for matplotlib colorbars python python

Top label for matplotlib colorbars


You could set the title of the colorbar axis (which appears above the axis), rather than the label (which appears along the long axis). To access the colorbar's Axes, you can use clb.ax. You can then use set_title, in the same way you can for any other Axes instance.

For example:

import numpy as npimport matplotlib.pylab as plt dat = np.random.randn(10,10)plt.imshow(dat, interpolation='none')clb = plt.colorbar()clb.ax.set_title('This is a title')plt.show()

enter image description here