diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 28a9a92550e8..a54150f6f3c2 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -893,7 +893,7 @@ def axline(self, xy1, xy2=None, *, slope=None, **kwargs): Returns ------- - `.Line2D` + `.AxLine` Other Parameters ---------------- diff --git a/lib/matplotlib/axes/_axes.pyi b/lib/matplotlib/axes/_axes.pyi index 9602db3b950c..1bfca8fc333d 100644 --- a/lib/matplotlib/axes/_axes.pyi +++ b/lib/matplotlib/axes/_axes.pyi @@ -18,7 +18,7 @@ from matplotlib.contour import ContourSet, QuadContourSet from matplotlib.image import AxesImage, PcolorImage from matplotlib.legend import Legend from matplotlib.legend_handler import HandlerBase -from matplotlib.lines import Line2D +from matplotlib.lines import Line2D, AxLine from matplotlib.mlab import GaussianKDE from matplotlib.patches import Rectangle, FancyArrow, Polygon, StepPatch, Wedge from matplotlib.quiver import Quiver, QuiverKey, Barbs @@ -151,7 +151,7 @@ class Axes(_AxesBase): *, slope: float | None = ..., **kwargs - ) -> Line2D: ... + ) -> AxLine: ... def axhspan( self, ymin: float, ymax: float, xmin: float = ..., xmax: float = ..., **kwargs ) -> Polygon: ... diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 42c177490cbb..fb925f1df62b 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -130,7 +130,7 @@ # We may not need the following imports here: from matplotlib.colors import Normalize -from matplotlib.lines import Line2D +from matplotlib.lines import Line2D, AxLine from matplotlib.text import Text, Annotation from matplotlib.patches import Polygon, Rectangle, Circle, Arrow from matplotlib.widgets import Button, Slider, Widget @@ -2721,7 +2721,7 @@ def axline( *, slope: float | None = None, **kwargs, -) -> Line2D: +) -> AxLine: return gca().axline(xy1, xy2=xy2, slope=slope, **kwargs)