shaare.it

ValueError: marker size must be positive

ValueError: marker size must be positive

$ python -c "import matplotlib.pyplot as plt; plt.plot([1,2,3], marker='o', markersize=-1)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: markersize must be positive

Why this happens

A negative or zero marker size was used.

Fix

Specify a positive marker size.

Wrong code

import matplotlib.pyplot as plt
plt.plot([1,2,3], marker='o', markersize=0)

Fixed code

import matplotlib.pyplot as plt
plt.plot([1,2,3], marker='o', markersize=6)
plt.show()