I need to add some text just upon one colobar to have a title for it. Is it possible ?
Here is one starting code coming from this post.
from matplotlib.pylab import *
import matplotlib.cm as cm
min_val = 0
max_val = 1
# See : http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps
my_cmap = cm.get_cmap('jet') # or any other one
norm = matplotlib.colors.Normalize(min_val, max_val) # the color maps work for [0, 1]
cmmapable = cm.ScalarMappable(norm, my_cmap)
cmmapable.set_array(range(min_val, max_val))
figure()
ax = gca()
cbar = colorbar(cmmapable, ticks=[0, 1])
cbar.ax.set_yticklabels(['Min', 'Max'])
show()
set_title should do what you want (doc)
cbar.ax.set_title('title')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With