0

I have the following Plot

plot

I need to add percentage inside the bars, it should be like this:

target

My code is the following:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sb

pkmn = pd.read_csv('data/Pokemon.csv')
pkmn.head()
order = pkmn['Generation'].value_counts().index
order
pkmngen = pkmn['Generation'].value_counts()

plt.figure(figsize=(6,4))
sb.countplot(data=pkmn, y='Generation', color = sb.color_palette()[4], order=order, )
plt.xticks(rotation=90)
plt.show()


  
tom10
  • 67,082
  • 10
  • 127
  • 137
abilio
  • 1
  • 1
  • 1
    Use [this approach](https://stackoverflow.com/questions/25447700/annotate-bars-with-values-on-pandas-bar-plots), using the `value_counts` from the original series with `Normalize=True` as your labels, and modify the label placement logic for a horizontal bar plot, instead of a regular bar plot. – BigBen Oct 15 '20 at 20:49
  • 1
    Please provide us with the data so we can reproduce the example. Thank you – Ehsan Oct 15 '20 at 21:25
  • Thanks, here it's de datasheet [csv](https://easyupload.io/0pel7l) – abilio Oct 15 '20 at 21:49

0 Answers0