【发布时间】:2019-12-10 16:56:13
【问题描述】:
我想根据我拥有的颜色图中反映的值对水平条形图的矩形进行着色。有没有办法遍历每个矩形并使颜色在颜色图上反映其值?
如果您有兴趣,这就是我正在使用的内容
我有我的 x 和 y 值并将它们放入一个正常的水平条形图中,就像这样,我在最后有一些标签表示这样的值:
plt.barh(x, y)
for i, v in enumerate(y):
ax.text(v + 1, i - .15 , str(v))
这是我要使用的颜色图:
fig, ax = plt.subplots(figsize=(0.5, 16))
colorBar = plt
fig.subplots_adjust(bottom=0.5)
cmap = mpl.cm.YlGn
norm = mpl.colors.Normalize(vmin=1, vmax=100)
cb1 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
norm=norm,
orientation='vertical')
fig.show()
【问题讨论】:
标签: python matplotlib