Skip to content

Overload the function signature of axline #29235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
9 changes: 8 additions & 1 deletion lib/matplotlib/axes/_axes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,22 @@ class Axes(_AxesBase):
self, x: float = ..., ymin: float = ..., ymax: float = ..., **kwargs
) -> Line2D: ...

# TODO: Could separate the xy2 and slope signatures
@overload
def axline(
self,
xy1: tuple[float, float],
xy2: tuple[float, float] | None = ...,
**kwargs
) -> AxLine: ...
@overload
def axline(
self,
xy1: tuple[float, float],
*,
slope: float | None = ...,
**kwargs
) -> AxLine: ...

def axhspan(
self, ymin: float, ymax: float, xmin: float = ..., xmax: float = ..., **kwargs
) -> Rectangle: ...
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2941,7 +2941,7 @@ def axline(
xy1: tuple[float, float],
xy2: tuple[float, float] | None = None,
*,
slope: float | None = None,
slope=None,
**kwargs,
) -> AxLine:
return gca().axline(xy1, xy2=xy2, slope=slope, **kwargs)
Expand Down
Loading