问题
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.
Thank you so much!
回答1:
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()
来源:https://stackoverflow.com/questions/46228180/python-seaborn-annotations-with-pointplot