我不明白为什么我的图例显示每个标记中的三个(我只想要一个)。
谷歌/stackoverflow 引导我找到 numpoints = 1
,但是我的问题仍然存在。有什么想法或建议吗?
代码:
fig, ax = plt.subplots(figsize=(14,7))
fig.patch.set_facecolor('white')
.....
markers = ["o", "s", "d", "v"]
for i in range(4):
plt.scatter([j for j in range(1,7)],
ygroup[i],
s = 38,
c = colours[i],
marker = markers[i],
edgecolors='none',
label = instloop[i])
ax.legend(loc = 'best', numpoints = 1)
show()
图片:
最佳答案
散点图有一个特殊的关键字参数 - 您希望将 scatterpoints=1
传递给 ax.legend()
关于python - 图例中的额外标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23704026/