我正在尝试将数千个逗号分隔符添加到下图中每个条上方的显示值中(例如,(当前)13815(希望是)13815)。我可以这样做的y轴。请告知
我的代码如下所示:
a = df.opp.value_counts().plot(kind='bar')
#annotate bar plot with values
for p in a.patches:
a.annotate(str(p.get_height()), (p.get_x() * 1.005, p.get_height() * 1.005))
a.set_yticklabels(['{:,}'.format(int(x)) for x in bar_uk19_opptype.get_yticks().tolist()])
使用:
a.annotate("{:,}".format(int(p.get_height())), (p.get_x() * 1.005, p.get_height() * 1.005))
编辑:刚刚意识到Aaron在评论alr中也有类似的ans
相关问题 更多 >
编程相关推荐