From ecfc8297cea78ee53cbdce45abb0e9721415d588 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 28 Apr 2022 12:52:31 -0400 Subject: [PATCH] BUG: Fix regression with ls=(0, ()) --- lib/matplotlib/backend_bases.py | 2 +- lib/matplotlib/tests/test_lines.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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()