我也不知道是什么ind
。但是如果目的是用它们的坐标来注释点,你可以ax.annotate
在一个映射到FacetGrid
如下的函数中使用:
import matplotlib.pyplot as plt
import seaborn as sns
attend = sns.load_dataset("attention")
sns.set_style("whitegrid", {'axes.grid' : False,'axes.edgecolor':'none'})
g = sns.FacetGrid(attend, col="subject", col_wrap=5,
size=1.5, ylim=(0, 10))
def f(x,y, **kwargs):
ax = sns.pointplot(x,y,**kwargs)
ax.axhline(5, alpha=0.5, color='grey')
for i in range(len(x)):
ax.annotate(str(y.values[i]), xy=(x.values[i]-1, y.values[i]),fontsize=8,
xytext = (0,10), textcoords="offset points",
color=kwargs.get("color","k"),
bbox=dict(pad=.9,alpha=0.2, fc='limegreen',color='none'),
va='center', ha='center',weight='bold')
g.map(f, "solutions", "score", scale=.7)
plt.show()

可能,您需要xy=(i, y.values[i])
在注释中使用,具体取决于数据的外观。
请注意,这也通过放入该函数来回答您之前的问题。axhline
如果目的是用注释替换点,则xytext = (0,0)
完全使用或不使用该论点;然后也在函数调用中保留bbox=dict(pad=.9,alpha=1, fc='w',color='none')
和使用:markers=""
import matplotlib.pyplot as plt
import seaborn as sns
attend = sns.load_dataset("attention")
sns.set_style("whitegrid", {'axes.grid' : False,'axes.edgecolor':'none'})
g = sns.FacetGrid(attend, col="subject", col_wrap=5,
size=1.5, ylim=(0, 10))
def f(x,y, **kwargs):
ax = sns.pointplot(x,y,**kwargs)
ax.axhline(5, alpha=0.5, color='grey')
for i in range(len(x)):
ax.annotate(str(y.values[i]), xy=(i, y.values[i]),fontsize=8,
color=kwargs.get("color","k"),
bbox=dict(pad=.9,alpha=1, fc='w',color='none'),
va='center', ha='center',weight='bold')
g.map(f, "solutions", "score", scale=.7, markers="")
plt.show()
