How can I add a point count in the point plot in seaborn?
df = pd.DataFrame({'group':[0,1,1],'percentage':[0.5, .3,.7],'value_group':[1,2,3], 'count':[1, 10, 20]})
df['value_group'] = pd.qcut(df.value_group, 2)
group percentage value_group count
0 0 0.5 1 1
1 1 0.3 2 10
2 1 0.7 3 20
With
sns.pointplot(x="value_group", y="percentage", hue="group", data=df)
I get:
But instead I would want:
How can this be achieved in seaborn?
edit
They are similar, but not the same. My value_group is obtained using pd.qcut
and the code referenced i.e. cannot handle these.
python Seaborn - annotations with pointplot
import matplotlib.pyplot as plt import seaborn as sns tips = sns.load_dataset("tips") ax = sns.pointplot(x="time", y="total_bill", hue="smoker", data=tips) for c in ax.collections: for of in c.get_offsets(): ax.annotate("Label", of) plt.show()
looks interesting, but so far I do not yet know how to match the right labels/indices with my counts.