How to show count values โ€‹โ€‹at the top of the panel in the counter?

I built a counter for the judges who gave the maximum number of matches in a cricket tournament. Used code:

ax=matches['umpires'].value_counts().head(10).plot.bar(width=.8) 

This displays the panel correctly, but the exact counter value does not appear at the top of each panel.

How to show the exact numbers on each bar?

+5
source share
1 answer

It seems to me that you need an iterrows and add new labels:

 np.random.seed(100) L = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') matches = pd.DataFrame(np.random.choice(L, size=(30,1)), columns=['umpires']) #print (matches) s = matches['umpires'].value_counts().head(10) print (s) C 5 Q 3 E 2 P 2 V 2 Y 2 H 1 D 1 M 1 J 1 Name: umpires, dtype: int64 ax=s.plot.bar(width=.8) for i, v in s.reset_index().iterrows(): ax.text(i, v.umpires + 0.2 , v.umpires, color='red') 

graph

+3
source

Source: https://habr.com/ru/post/1264073/


All Articles