From 7a279ddd8042226ec7edf2a489d928cc37476468 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Mon, 28 Feb 2022 00:28:06 +0100 Subject: [PATCH] Require non-zero dash value --- lib/matplotlib/backend_bases.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 0c7893b81977..76bc1e931e29 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -912,7 +912,8 @@ def set_dashes(self, dash_offset, dash_list): dash_offset : float The offset (usually 0). dash_list : array-like or None - The on-off sequence as points. None specifies a solid line. + The on-off sequence as points. None specifies a solid line. All + values must otherwise be non-negative (:math:`\\ge 0`). Notes ----- @@ -924,7 +925,10 @@ def set_dashes(self, dash_offset, dash_list): dl = np.asarray(dash_list) if np.any(dl < 0.0): raise ValueError( - "All values in the dash list must be positive") + "All values in the dash list must be non-negative") + if 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 def set_foreground(self, fg, isRGBA=False):