diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 66a52f7faabf..54afb7b565b9 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()