Is it possible to annotate each point in a seaborn.stipplot? My data is in pandas. I realize that annotate works for matplotlib, but I have not found it to work in this case.
            Asked
            
        
        
            Active
            
        
            Viewed 3,318 times
        
    3
            
            
        
        Trenton McKinney
        
- 56,955
 - 33
 - 144
 - 158
 
        amc
        
- 813
 - 1
 - 15
 - 28
 
1 Answers
8
            seaborn is a high-level API for matplotlib, so assign the returned axes to an alias, and then use the object with .annotate.
This example is adapted from the seaborn docs here.
Tested in python 3.11.2, pandas 2.0.0, matplotlib 3.7.1, seaborn 0.12.2
import seaborn as sns
tips = sns.load_dataset("tips")
sat_mean = tips.loc[tips['day'] == 'Sat']['total_bill'].mean()
ax = sns.stripplot(x="day", y="total_bill", data=tips)
ax.annotate("Saturday\nMean",
            xy=(2, sat_mean), xycoords='data',
            xytext=(.5, .5), textcoords='axes fraction',
            horizontalalignment="center",
            arrowprops=dict(arrowstyle="->",
                            connectionstyle="arc3"),
            bbox=dict(boxstyle="round", fc="w"),
            )
# ax.get_figure().savefig('tips_annotation.png')
        Trenton McKinney
        
- 56,955
 - 33
 - 144
 - 158
 
        aorr
        
- 937
 - 7
 - 9
 
