Ray*_*y92 1 python matplotlib pandas
我一直在尝试绘制每个条形图上带有值标签的条形图。我已经到处搜索但无法完成此操作。我的 df 是下面这个。
Pillar %
Exercise 19.4
Meaningful Activity 19.4
Sleep 7.7
Nutrition 22.9
Community 16.2
Stress Management 23.9
Run Code Online (Sandbox Code Playgroud)
到目前为止我的代码是
df_plot.plot(x ='Pillar', y='%', kind = 'bar')
plt.show()
Run Code Online (Sandbox Code Playgroud)
使用ax.bar_label:
ax = df.plot(x='Pillar', y='%', kind='bar', legend=False, rot=0)
ax.bar_label(ax.containers[0], label_type='edge')
plt.tight_layout()
Run Code Online (Sandbox Code Playgroud)