Issue
I have been trying to get a bar plot with value labels on each bar. I have searched all over but can't get this done. My df is the one below.
Pillar %
Exercise 19.4
Meaningful Activity 19.4
Sleep 7.7
Nutrition 22.9
Community 16.2
Stress Management 23.9
My code so far is
df_plot.plot(x ='Pillar', y='%', kind = 'bar')
plt.show()
Solution
Use 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()
Answered By - Corralien
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.