From 1363f19b43fcfe1a2283758fb2e86cd514fb69e4 Mon Sep 17 00:00:00 2001 From: johan12345 Date: Tue, 9 Feb 2021 22:46:41 +0100 Subject: [PATCH 1/2] fix regression of axline behavior with non-linear scales fixes #19445 --- lib/matplotlib/lines.py | 3 ++- lib/matplotlib/tests/test_axes.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 66a52f7faabf..d6893d5d7c29 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -1432,7 +1432,8 @@ def __init__(self, xy1, xy2, slope, **kwargs): def get_transform(self): ax = self.axes - points_transform = self._transform + ax.transData.inverted() + points_transform = self._transform + ax.transData.inverted()\ + + ax.transScale if self._xy2 is not None: # two points were given diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 2c364962aab6..22775989a708 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -4103,6 +4103,19 @@ def test_eb_line_zorder(): ax.set_title("errorbar zorder test") +@check_figures_equal() +def test_axline_loglog(fig_test, fig_ref): + ax = fig_test.subplots() + ax.set(xlim=(0.1, 10), ylim=(1e-3, 1)) + ax.loglog([.3, .6], [.3, .6], ".-") + ax.axline((1, 1e-3), (10, 1e-2), c="k") + + ax = fig_ref.subplots() + ax.set(xlim=(0.1, 10), ylim=(1e-3, 1)) + ax.loglog([.3, .6], [.3, .6], ".-") + ax.loglog([1, 10], [1e-3, 1e-2], c="k") + + @check_figures_equal() def test_axline(fig_test, fig_ref): ax = fig_test.subplots() From 025b2ee30acd9d6ee6ea94323e617cc4e1895b32 Mon Sep 17 00:00:00 2001 From: johan12345 Date: Wed, 10 Feb 2021 09:16:59 +0100 Subject: [PATCH 2/2] avoid line continuation character --- lib/matplotlib/lines.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index d6893d5d7c29..54afb7b565b9 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -1432,8 +1432,8 @@ def __init__(self, xy1, xy2, slope, **kwargs): def get_transform(self): ax = self.axes - points_transform = self._transform + ax.transData.inverted()\ - + ax.transScale + points_transform = (self._transform + ax.transData.inverted() + + ax.transScale) if self._xy2 is not None: # two points were given