【问题标题】:Setting the labels of colorbar matplotlib设置colorbar matplotlib的标签
【发布时间】:2020-06-04 16:00:37
【问题描述】:

我花了几个小时试图弄清楚这一点。我希望颜色条沿条形显示三个值,[0, 3315/2, 3315]。但是,我只是得到这个结果:

代码:

print(max(average_powers)) # 3314.455810547
sm = plt.cm.ScalarMappable(cmap=cmap)
sm.set_array([])
mn=int(np.floor(0)) 3 
mx=int(np.ceil(max(average_powers)))
md=(mx-mn)/2
cb = plt.colorbar(sm)
cb.set_ticks([mn,md,mx])
cb.set_ticklabels([mn,md,mx],update_ticks=True)
cb.set_label('Magnitude of Average Power for turbine')

提前致谢!

【问题讨论】:

  • matplotlib demo 有帮助吗?
  • 只是顺便说一下你的图表很漂亮!

标签: python matplotlib colorbar


【解决方案1】:

替换

cb.set_ticks([mn,md,mx])

cb.set_ticks([0, 0.5, 1])

【讨论】:

    猜你喜欢
    • 2016-05-04
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 2021-04-28
    • 2012-05-11
    • 2013-03-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多