gpt4 book ai didi

python - matplotlib 图例标记仅一次

转载 作者:IT老高 更新时间:2023-10-28 12:11:13 26 4
gpt4 key购买 nike

我经常在 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 文件,那么这将是新的默认值。

[另请参见散点,具体取决于您的情节。]

API:Link to API docs

关于python - matplotlib 图例标记仅一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6146778/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com