我经常使用以下命令在matplotlib绘图上绘制点:
x = 10
y = 100
plot(x, y, "k*", label="Global Optimum")
legend()
但是,这会导致图例在图例中放置一颗星星两次,看起来像:
* * Global Optimum
当我真的想要它看起来像:
* Global Optimum
我该怎么做?
我经常使用以下命令在matplotlib绘图上绘制点:
x = 10
y = 100
plot(x, y, "k*", label="Global Optimum")
legend()
但是,这会导致图例在图例中放置一颗星星两次,看起来像:
* * Global Optimum
当我真的想要它看起来像:
* Global Optimum
我该怎么做?
这应该是可行的:
legend(numpoints=1)
顺便说一句,如果你加上这一行
legend.numpoints : 1 # the number of points in the legend line
到matplotlibrc文件,则这将是新的默认值.
[另请参见散点,具体取决于您的情节.]
空气污染指数:Link to API docs