我需要在一个文本上添加一些文本colobar
以获得它的标题。可能吗 ?
这是来自这篇文章的一个起始代码。
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()