bakun
bakun

Reputation: 475

Show axhline value python

I've placed a horizontal line in a vertical bar char (with the average), and I want the value to be shown. (pointing to the line)

fig = plt.figure()
ax0 = fig.add_subplot(1, 3, 1) 
cluster2_restaurants.plot(kind='bar', figsize=(25, 6), ax = ax0)
ax0.axhline(cluster2['Restaurants'].mean(), color='green', linewidth=2)

The graph

Upvotes: 1

Views: 1072

Answers (1)

r-beginners
r-beginners

Reputation: 35115

You can set this up as an example of adding text. Set the average value at position 0 on the x-axis.

offset = 2
ax0.text(0, cluster2['Restaurants'].mean()+offset, cluster2['Restaurants'].mean())

Upvotes: 1

Related Questions