是否可以在 seaborn 的带状图上标注每个点?我的数据在 Pandas 数据框中。我知道注释适用于 matplotlib,但我发现它在这种情况下不起作用。
最佳答案
您只需要返回 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')
关于pandas - 使用 Pandas 数据框在 Seaborn stripplot 中注释点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44077661/