Skip to content

Commit f072289

Browse files
committed
FIX: axhline() / axvline() now always do autoscaling
Closes matplotlib#14651. As they are regularly added wih `add_line()`, they were always added to the data limits, but autoscaling was only updated under certain conditions, which led to an inconsistent state. See matplotlib#14651 (comment) Because of the inconsistent state, I'll classify this as a bug fix and justify that change can happen immediately without a deprecation.
1 parent fee65f1 commit f072289

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,14 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
818818

819819
# Strip away the units for comparison with non-unitized bounds.
820820
yy, = self._process_unit_info([("y", y)], kwargs)
821-
scaley = (yy < ymin) or (yy > ymax)
822821

823822
trans = self.get_yaxis_transform(which='grid')
824823
l = mlines.Line2D([xmin, xmax], [y, y], transform=trans, **kwargs)
825824
self.add_line(l)
826825
l.get_path()._interpolation_steps = mpl.axis.GRIDLINE_INTERPOLATION_STEPS
827-
if scaley:
828-
self._request_autoscale_view("y")
826+
827+
self._request_autoscale_view("y")
828+
829829
return l
830830

831831
@_docstring.interpd
@@ -901,14 +901,14 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
901901

902902
# Strip away the units for comparison with non-unitized bounds.
903903
xx, = self._process_unit_info([("x", x)], kwargs)
904-
scalex = (xx < xmin) or (xx > xmax)
905904

906905
trans = self.get_xaxis_transform(which='grid')
907906
l = mlines.Line2D([x, x], [ymin, ymax], transform=trans, **kwargs)
908907
self.add_line(l)
909908
l.get_path()._interpolation_steps = mpl.axis.GRIDLINE_INTERPOLATION_STEPS
910-
if scalex:
911-
self._request_autoscale_view("x")
909+
910+
self._request_autoscale_view("x")
911+
912912
return l
913913

914914
@staticmethod

0 commit comments

Comments
 (0)