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 np
import 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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)