-1

I'm looking to display the actual count value of a bar in countplot graph.

When I enter sns.countplot(x=df["Party"])

I get an output of output

I'm just looking to have the actual value displayed above each bar.

2 Answers2

0

I don't know what dataset you're using so I'm gonna use a hypothetical one, but this should work.

import seaborn as sns
import pandas as pd

df = pd.read_csv(my_path_to_csv) # hypothetical csv file
ax = sns.barplot(x='x', y='y', data=df) # barplot usage

# the actual part that adds labels
for i in ax.containers:
    ax.bar_labels(i,)
rsenne
  • 142
  • 6
0

Try Uisng matplotlib.pyplot.bar_label

python 3
matplotlib should be > 3.4

Then

plot = sns.countplot(x=df["Party"])
plot.bar_label(plot.containers[0], label_type='edge')
plt.show()