使用 Pandas 数据框在 Seaborn stripplot 中注释点

Annotate points in Seaborn stripplot with Pandas dataframe

是否可以在seaborn的条带图上标注每个点?我的数据在 pandas 数据框中。我知道注释适用于 matplotlib,但我没有发现它在这种情况下有效。

您只需要 return axes 对象。下面的示例改编自 seaborn 文档 here:

import seaborn as sns

sns.set_style("whitegrid")
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')