Skip to content

Backport PR #21017 on branch v3.5.x (FIX: Don't subslice lines if non-standard transform) #21032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand Down