ValueError: Unrecognized linestyle
7 Dec 2025
1 min read
ValueError: Unrecognized linestyle
$ python plot.py
Traceback (most recent call last):
...
ValueError: Unrecognized linestyle 'dashed-line'
Why this happens
You provided a string for the linestyle (or ls) argument that isn’t a valid Matplotlib line style code.
Fix
Use one of the supported line style strings: '-', '--', '-.', ':', or 'solid', 'dashed', 'dashdot', 'dotted'.
Wrong code
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], linestyle='dashed-line')
Fixed code
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], linestyle='--') # or 'dashed'