shaare.it

ValueError: Unrecognized linestyle

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'