From 7c3147bcb6d88557600d743da5fb167a24c4e202 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Wed, 8 Sep 2021 09:15:34 +0200 Subject: [PATCH 1/2] FIX: Don't subslice lines if non-standar transform --- lib/matplotlib/lines.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 9a727f9a8107..e3bfced3cf21 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -664,7 +664,8 @@ def recache(self, always=False): self.axes.name == 'rectilinear' and self.axes.get_xscale() == 'linear' and self._markevery is None and - self.get_clip_on()): + self.get_clip_on() and + self.get_transform() == self.axes.transData): self._subslice = True nanmask = np.isnan(x) if nanmask.any(): From eba5cdcf0fc9aeb0134a71b955b25a6a413857d6 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Wed, 8 Sep 2021 14:01:16 +0200 Subject: [PATCH 2/2] TST: add test for no subslice if we have a non-standard transform --- lib/matplotlib/tests/test_lines.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/matplotlib/tests/test_lines.py b/lib/matplotlib/tests/test_lines.py index 21cb2214051a..f6917a134bb4 100644 --- a/lib/matplotlib/tests/test_lines.py +++ b/lib/matplotlib/tests/test_lines.py @@ -16,6 +16,7 @@ from matplotlib.markers import MarkerStyle from matplotlib.path import Path import matplotlib.pyplot as plt +import matplotlib.transforms as mtransforms from matplotlib.testing.decorators import image_comparison, check_figures_equal @@ -131,6 +132,17 @@ def test_drawstyle_variants(): ax.set(xlim=(0, 2), ylim=(0, 2)) +@check_figures_equal(extensions=('png',)) +def test_no_subslice_with_transform(fig_ref, fig_test): + ax = fig_ref.add_subplot() + x = np.arange(2000) + ax.plot(x + 2000, x) + + ax = fig_test.add_subplot() + t = mtransforms.Affine2D().translate(2000.0, 0.0) + ax.plot(x, x, transform=t+ax.transData) + + def test_valid_drawstyles(): line = mlines.Line2D([], []) with pytest.raises(ValueError):