Issue
results = df.groupby('depart')['Survey'].mean().to_frame(name = 'Mean').reset_index()
results.plot(x = 'Unit', y = 'Mean', marker = 'o', figsize=(8,5))
plt.grid(True)
plt.ylim(3.60, 5.00)
plt.show()
how do I add the value labels on top of the markers?
thanks!
Solution
One way is using annotate
results.plot(x = 'Unit', y = 'Mean', marker = 'o', figsize=(8,5))
plt.grid(True)
plt.ylim(3.60, 5.00)
ax = plt.gca()
for i, val in enumerate(results['Mean']):
label = results.loc[i, 'Mean']
ax.annotate(label, (i, val), ha='center')
plt.show()
Answered By - Himanshuman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.