diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 0e7ee91a0a8c..44f49f43e7de 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -924,7 +924,7 @@ def set_dashes(self, dash_offset, dash_list): if np.any(dl < 0.0): raise ValueError( "All values in the dash list must be non-negative") - if not np.any(dl > 0.0): + if dl.size and not np.any(dl > 0.0): raise ValueError( 'At least one value in the dash list must be positive') self._dashes = dash_offset, dash_list diff --git a/lib/matplotlib/tests/test_lines.py b/lib/matplotlib/tests/test_lines.py index 1014267f60f5..e302ddf5e494 100644 --- a/lib/matplotlib/tests/test_lines.py +++ b/lib/matplotlib/tests/test_lines.py @@ -108,7 +108,9 @@ def test_valid_colors(): def test_linestyle_variants(): fig, ax = plt.subplots() for ls in ["-", "solid", "--", "dashed", - "-.", "dashdot", ":", "dotted"]: + "-.", "dashdot", ":", "dotted", + (0, None), (0, ()), (0, []), # gh-22930 + ]: ax.plot(range(10), linestyle=ls) fig.canvas.draw()