Annotations with pointplot

2.6k views Asked by At

I am using a pointplot in seaborn.

import seaborn as sns
sns.set_style("darkgrid")
tips = sns.load_dataset("tips")
ax = sns.pointplot(x="time", y="total_bill", hue="smoker",data=tips)

I would like to annotate all of the points. If there are points in between, I would like to label the points in between along with the line ends if that makes sense.

Thank you so much!

1

There are 1 answers

0
ImportanceOfBeingErnest On

The question is rather unspecific, but here is how to label each point in a pointplot, just as you would do with any other matplotlib scatter plot:

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()

enter image description here