您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python pandas / matplotlib在条形图列上方注释标签

Python pandas / matplotlib在条形图列上方注释标签

捕获绘图所在的轴,然后将其作为普通matplotlib对象进行操作。将值放在条形上方将是这样的:

ax = df.plot(kind='bar',  title='scores')
ax.set_ylim(0, 12)
for i, label in enumerate(list(df.index)):
    score = df.ix[label]['score']
    ax.annotate(str(score), (i, score + 0.2))
python 2022/1/1 18:34:26 有444人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶