2017-03-08 94 views
0

我有以下matplotlib代码:的Python matplotlib:加上酒吧的顶部计数

ax = my_df.plot(x='arrival_month', y='my_count' ,kind='bar', figsize = (20,10), fontsize = 16, color = 'b', alpha = 0.3) 
ax.set_xticklabels([t.get_text().split(" ")[0] for t in ax.get_xticklabels()]) 
ax.set_ylim([-50,300]) 
plt.show() 

生成的数字:

enter image description here

我想知道是否有可能加入计数在酒吧顶部,如:

enter image description here

非常感谢!

回答

0

喜欢的东西上循环

ax.annotate('(%s, %s)' % xy, xy=xy, textcoords='data')

应该工作,其中xy是代表的每个坐标的x和y值的元组。

这建议在answer to another question

如果您提供MWE,我们也可以测试我们的建议。特别是告诉我们什么my_df看起来像,会有所帮助。