如何创建每个标签只有一个符号的散点图图例? [英] How to create a scatter plot legend with only one symbol for each label?

查看:90
本文介绍了如何创建每个标签只有一个符号的散点图图例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建不显示两个符号的散点图图例?我能理解为什么在按行连接符号时为什么要这样做,但是对于纯散点图,我在图例中只需要一个符号示例.上一篇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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆