本文介绍了使用Pandas数据框注释Seaborn条形图中的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在seaborn的带状图中注释每个点?我的数据在pandas数据框中.我意识到注释适用于matplotlib,但在这种情况下我没有发现它有效.
Is it possible to annotate each point on a stripplot in seaborn? My data is in the pandas dataframe. I realize that annotate works for matplotlib but I have not found it to work in this case.
推荐答案
您只需要返回axes
对象.下面的示例改编自seaborn
文档此处:
You just need to return the axes
object. The example below is adapted from the seaborn
docs 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数据框注释Seaborn条形图中的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!