Matplotlib Legend has two stars

Asked 2 years ago, Updated 2 years ago, 70 views

I usually make it like this when I take only one dot in matplotlib

from matplotlib.pyplot import *

x = 10
y = 100
plot(x, y, "k*", label="Global Optimum")
legend()
show()

But when I did this, the star was marked twice like * * Global Optimum on the legend.

I want to make * Global Optimum appear only once, but how can I reduce the number of stars?

python matplotlib

2022-09-22 08:13

1 Answers

legend(numpoints=1)

Call legend to .

Since the author said, "We usually do this," to fix one asterisk with the default setting, use the matplotlibc file

legend.numpoints     : 1      # the number of points in the legend line

Please add.


2022-09-22 08:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.