python Seaborn - 带有点图的注释 [英] python Seaborn - annotations with pointplot
本文介绍了python Seaborn - 带有点图的注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 seaborn 中使用点图.
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.
非常感谢!
推荐答案
这个问题相当不具体,但这里是如何标记点图中的每个点,就像您对任何其他 matplotlib 散点图所做的一样:
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()
这篇关于python Seaborn - 带有点图的注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文