2017-03-08 23 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看起來像,會有所幫助。