Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/artist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Artist:
def set_visible(self, b: bool) -> None: ...
def set_animated(self, b: bool) -> None: ...
def set_in_layout(self, in_layout: bool) -> None: ...
def get_label(self) -> object: ...
def get_label(self) -> str: ...
def set_label(self, s: object) -> None: ...
def get_zorder(self) -> float: ...
def set_zorder(self, level: float) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class Axis(martist.Artist):
) -> Bbox | None: ...
def get_tick_padding(self) -> float: ...
def get_gridlines(self) -> list[Line2D]: ...
def get_label(self) -> Text: ...
def get_label(self) -> Text: ... # type: ignore[override]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a side note, this inconsistent use of label is discussed in #29422.

def get_offset_text(self) -> Text: ...
def get_pickradius(self) -> float: ...
def get_majorticklabels(self) -> list[Text]: ...
Expand Down
42 changes: 34 additions & 8 deletions lib/matplotlib/legend_handler.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Callable, Sequence
from typing import Protocol, TypedDict, Unpack

from numpy.typing import ArrayLike

Expand All @@ -9,6 +10,11 @@ from matplotlib.transforms import Transform

def update_from_first_child(tgt: Artist, src: Artist) -> None: ...

class _BaseKwargs(TypedDict, total=False):
xpad: float
ypad: float
update_func: Callable[[Artist, Artist], None] | None

class HandlerBase:
def __init__(
self,
Expand Down Expand Up @@ -46,7 +52,7 @@ class HandlerBase:

class HandlerNpoints(HandlerBase):
def __init__(
self, marker_pad: float = ..., numpoints: int | None = ..., **kwargs
self, marker_pad: float = ..., numpoints: int | None = ..., **kwargs: Unpack[_BaseKwargs]
) -> None: ...
def get_numpoints(self, legend: Legend) -> int | None: ...
def get_xdata(
Expand All @@ -64,7 +70,10 @@ class HandlerNpointsYoffsets(HandlerNpoints):
self,
numpoints: int | None = ...,
yoffsets: Sequence[float] | None = ...,
**kwargs
*,
# From HandlerNpoints
marker_pad: float = ...,
**kwargs: Unpack[_BaseKwargs]
) -> None: ...
def get_ydata(
self,
Expand Down Expand Up @@ -102,8 +111,21 @@ class HandlerLine2D(HandlerNpoints):
trans: Transform,
) -> Sequence[Artist]: ...

class _PatchFunc(Protocol):
def __call__(
self,
*,
legend: Legend = ...,
orig_handle: Artist = ...,
xdescent: float = ...,
ydescent: float = ...,
width: float = ...,
height: float = ...,
fontsize: float = ...,
) -> Artist: ...

class HandlerPatch(HandlerBase):
def __init__(self, patch_func: Callable | None = ..., **kwargs) -> None: ...
def __init__(self, patch_func: _PatchFunc | None = ..., **kwargs: Unpack[_BaseKwargs]) -> None: ...
def create_artists(
self,
legend: Legend,
Expand Down Expand Up @@ -148,7 +170,11 @@ class HandlerRegularPolyCollection(HandlerNpointsYoffsets):
self,
yoffsets: Sequence[float] | None = ...,
sizes: Sequence[float] | None = ...,
**kwargs
*,
# From HandlerNpoints
marker_pad: float = ...,
numpoints: int | None = ...,
**kwargs: Unpack[_BaseKwargs]
) -> None: ...
def get_numpoints(self, legend: Legend) -> int: ...
def get_sizes(
Expand All @@ -162,7 +188,7 @@ class HandlerRegularPolyCollection(HandlerNpointsYoffsets):
fontsize: float,
) -> Sequence[float]: ...
def update_prop(
self, legend_handle, orig_handle: Artist, legend: Legend
self, legend_handle: Artist, orig_handle: Artist, legend: Legend
) -> None: ...
def create_collection[T: Artist](
self,
Expand Down Expand Up @@ -208,7 +234,7 @@ class HandlerErrorbar(HandlerLine2D):
yerr_size: float | None = ...,
marker_pad: float = ...,
numpoints: int | None = ...,
**kwargs
**kwargs: Unpack[_BaseKwargs]
) -> None: ...
def get_err_size(
self,
Expand Down Expand Up @@ -238,7 +264,7 @@ class HandlerStem(HandlerNpointsYoffsets):
numpoints: int | None = ...,
bottom: float | None = ...,
yoffsets: Sequence[float] | None = ...,
**kwargs
**kwargs: Unpack[_BaseKwargs]
) -> None: ...
def get_ydata(
self,
Expand All @@ -263,7 +289,7 @@ class HandlerStem(HandlerNpointsYoffsets):

class HandlerTuple(HandlerBase):
def __init__(
self, ndivide: int | None = ..., pad: float | None = ..., **kwargs
self, ndivide: int | None = ..., pad: float | None = ..., **kwargs: Unpack[_BaseKwargs]
) -> None: ...
def create_artists(
self,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/offsetbox.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PackerBase(OffsetBox):
height: float | None = ...,
align: Literal["top", "bottom", "left", "right", "center", "baseline"] = ...,
mode: Literal["fixed", "expand", "equal"] = ...,
children: list[martist.Artist] | None = ...,
children: Sequence[martist.Artist] | None = ...,
) -> None: ...

class VPacker(PackerBase): ...
Expand Down
Loading