Skip to content

Commit 41a90c6

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR #21017: FIX: Don't subslice lines if non-standard transform
1 parent f943875 commit 41a90c6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/matplotlib/lines.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ def recache(self, always=False):
664664
self.axes.name == 'rectilinear' and
665665
self.axes.get_xscale() == 'linear' and
666666
self._markevery is None and
667-
self.get_clip_on()):
667+
self.get_clip_on() and
668+
self.get_transform() == self.axes.transData):
668669
self._subslice = True
669670
nanmask = np.isnan(x)
670671
if nanmask.any():

lib/matplotlib/tests/test_lines.py

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from matplotlib.markers import MarkerStyle
1717
from matplotlib.path import Path
1818
import matplotlib.pyplot as plt
19+
import matplotlib.transforms as mtransforms
1920
from matplotlib.testing.decorators import image_comparison, check_figures_equal
2021

2122

@@ -131,6 +132,17 @@ def test_drawstyle_variants():
131132
ax.set(xlim=(0, 2), ylim=(0, 2))
132133

133134

135+
@check_figures_equal(extensions=('png',))
136+
def test_no_subslice_with_transform(fig_ref, fig_test):
137+
ax = fig_ref.add_subplot()
138+
x = np.arange(2000)
139+
ax.plot(x + 2000, x)
140+
141+
ax = fig_test.add_subplot()
142+
t = mtransforms.Affine2D().translate(2000.0, 0.0)
143+
ax.plot(x, x, transform=t+ax.transData)
144+
145+
134146
def test_valid_drawstyles():
135147
line = mlines.Line2D([], [])
136148
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)