From c3b82f77a3884e4e3cbcb42ac84f769f7e9a088e Mon Sep 17 00:00:00 2001 From: Ruth Comer <10599679+rcomer@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:00:01 +0000 Subject: [PATCH] FIX: zero width lines need no pattern --- lib/matplotlib/lines.py | 2 +- lib/matplotlib/tests/test_collections.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 65a4ccb6d950..a26ac72e2c1a 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -77,7 +77,7 @@ def _scale_dashes(offset, dashes, lw): return offset, dashes scaled_offset = offset * lw scaled_dashes = ([x * lw if x is not None else None for x in dashes] - if dashes is not None else None) + if dashes is not None and lw > 0 else None) return scaled_offset, scaled_dashes diff --git a/lib/matplotlib/tests/test_collections.py b/lib/matplotlib/tests/test_collections.py index 11934cfca2c3..10631120c54b 100644 --- a/lib/matplotlib/tests/test_collections.py +++ b/lib/matplotlib/tests/test_collections.py @@ -680,6 +680,16 @@ def test_set_wrong_linestyle(): c.set_linestyle('fuzzy') +@mpl.style.context('default') +def test_zero_linewidth_scaling(): + c = Collection() + c.set_linestyle('dashed') + c.set_linewidth(0) + + # With a zero linewidth, there can be no pattern + assert c.get_linestyle() == [(0, None)] + + @mpl.style.context('default') def test_capstyle(): col = mcollections.PathCollection([]) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy