如何创建每个标签只有一个符号的散点图图例? [英] How to create a scatter plot legend with only one symbol for each label?
问题描述
如何创建不显示两个符号的散点图图例?我能理解为什么在按行连接符号时为什么要这样做,但是对于纯散点图,我在图例中只需要一个符号示例.上一篇stackoverflow帖子中的图显示了我的意思:
How can I create a scatter plot legend without two symbols showing up each time? I can understand why you'd want this when you're joining symbols by lines, but for a pure scatter plot, all I want in the legend is one example of the symbol. This plot from a previous stackoverflow post shows the kind of thing I mean:
推荐答案
在legend
命令中,您可以使用scatterpoints
选项:
In the legend
command you can use the scatterpoints
option:
ax.legend(loc=0, scatterpoints = 1)
对于法线图,它是选项numpoints
.
For a normal plot, it is the option numpoints
.
在这里您可以找到有关图例的关键字参数的更多信息: http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend
Here you can find more information about the keyword arguments for the legend: http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend
这篇关于如何创建每个标签只有一个符号的散点图图例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!