每个点都有不同文本的散点图

问题描述 投票:0回答:0

我必须做一个散点图,我想显示每个点的名称。 比如像

plt.xlabel="pears sold"
plt.ylabel="melons sold"

我想为散点的每个点显示

sellers
的名称

sellers
是我的 df 中存在的一个专栏。 看完另一个问题后,我试了一下

for p, txt in enumerate(sellers):
    ax.annotate(txt, (pears sold[p], melons sold[p]))

但是它返回这个错误

NameError: name 'sellers' is not defined

问题是

player
栏太大,无法手动写入。我该如何解决?

编辑:我解决了那个问题,但我现在有另一个问题

    ax.annotate(n, (df["pears sold"][p], dfscatter["melons sold"][p]))```

It gives me this kind of error

> # If we have a listlike key, _check_indexing_error will raise
KeyError: 0
matplotlib seaborn scatter-plot
© www.soinside.com 2019 - 2024. All rights reserved.