捕获绘图所在的轴,然后将其作为普通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 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))