Skip to content

Commit e24244c

Browse files
authored
Merge pull request #19485 from johan12345/master
fix regression of axline behavior with non-linear scales
2 parents 8ff6e8a + 025b2ee commit e24244c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/matplotlib/lines.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,8 @@ def __init__(self, xy1, xy2, slope, **kwargs):
14321432

14331433
def get_transform(self):
14341434
ax = self.axes
1435-
points_transform = self._transform + ax.transData.inverted()
1435+
points_transform = (self._transform + ax.transData.inverted() +
1436+
ax.transScale)
14361437

14371438
if self._xy2 is not None:
14381439
# two points were given

lib/matplotlib/tests/test_axes.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4103,6 +4103,19 @@ def test_eb_line_zorder():
41034103
ax.set_title("errorbar zorder test")
41044104

41054105

4106+
@check_figures_equal()
4107+
def test_axline_loglog(fig_test, fig_ref):
4108+
ax = fig_test.subplots()
4109+
ax.set(xlim=(0.1, 10), ylim=(1e-3, 1))
4110+
ax.loglog([.3, .6], [.3, .6], ".-")
4111+
ax.axline((1, 1e-3), (10, 1e-2), c="k")
4112+
4113+
ax = fig_ref.subplots()
4114+
ax.set(xlim=(0.1, 10), ylim=(1e-3, 1))
4115+
ax.loglog([.3, .6], [.3, .6], ".-")
4116+
ax.loglog([1, 10], [1e-3, 1e-2], c="k")
4117+
4118+
41064119
@check_figures_equal()
41074120
def test_axline(fig_test, fig_ref):
41084121
ax = fig_test.subplots()

0 commit comments

Comments
 (0)