2017-09-14 49 views
-1

我在seaborn中使用了一個點圖。python Seaborn - 帶有pointplot的註釋

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) 

我想註釋所有要點。如果兩者之間有分數,我希望將它們之間的分數與分數線標記在一起,如果有意義的話。

非常感謝!

回答

0

的問題是相當非特異性的,但在這裏是如何標記每個點在pointplot,就像你會與任何其他matplotlib散點圖做:

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() 

enter image description here