python - Displaying of values on barchart -




i've found couple of similar postings topic. wasn't helpful me.

i'm relatively new python , seaborn.

this code:

import seaborn sns import matplotlib.pyplot plt %matplotlib inline  x_axis = ["a", "b","c","d","e","f"] y_axis = [78.5, 79.6, 81.6, 75.4, 78.3, 79.6]  plt.ylabel('accuracy') plt.title('accuracy of classifier')  g=sns.barplot(x_axis, y_axis, color="red") 

i'm trying display values y_axis on top of every bar.

loop through patches , annotate bars.

import seaborn sns import matplotlib.pyplot plt %matplotlib inline  x_axis = ["a", "b","c","d","e","f"] y_axis = [78.5, 79.6, 81.6, 75.4, 78.3, 79.6]  plt.ylabel('accuracy') plt.title('accuracy of classifier')  g=sns.barplot(x_axis, y_axis, color="red") ax=g #annotate axis = seaborn axis p in ax.patches:              ax.annotate("%.2f" % p.get_height(), (p.get_x() + p.get_width() / 2., p.get_height()),                  ha='center', va='center', fontsize=11, color='gray', xytext=(0, 20),                  textcoords='offset points') _ = g.set_ylim(0,120) #to make space annotations 

output:

enter image description here





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -