Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TYP: Fix some small bugs #26656

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

Merged
merged 3 commits into from
Aug 31, 2023
Merged
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
6 changes: 4 additions & 2 deletions lib/matplotlib/_pylab_helpers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from matplotlib.figure import Figure
class Gcf:
figs: OrderedDict[int, FigureManagerBase]
@classmethod
def get_fig_manager(cls, num: int) -> FigureManagerBase: ...
def get_fig_manager(cls, num: int) -> FigureManagerBase | None: ...
@classmethod
def destroy(cls, num: int | FigureManagerBase) -> None: ...
@classmethod
Expand All @@ -20,7 +20,9 @@ class Gcf:
@classmethod
def get_num_fig_managers(cls) -> int: ...
@classmethod
def get_active(cls) -> FigureManagerBase: ...
def get_active(cls) -> FigureManagerBase | None: ...
@classmethod
def _set_new_active_manager(cls, manager: FigureManagerBase) -> None: ...
@classmethod
def set_active(cls, manager: FigureManagerBase) -> None: ...
@classmethod
Expand Down
7 changes: 5 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def legend(self, *args, **kwargs):

Parameters
----------
handles : sequence of `.Artist`, optional
handles : sequence of (`.Artist` or tuple of `.Artist`), optional
A list of Artists (lines, patches) to be added to the legend.
Use this together with *labels*, if you need full control on what
is shown in the legend and the automatic mechanism described above
Expand All @@ -289,6 +289,9 @@ def legend(self, *args, **kwargs):
The length of handles and labels should be the same in this
case. If they are not, they are truncated to the smaller length.

If an entry contains a tuple, then the legend handler for all Artists in the
tuple will be placed alongside a single label.

labels : list of str, optional
A list of labels to show next to the artists.
Use this together with *handles*, if you need full control on what
Expand Down Expand Up @@ -3436,7 +3439,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
If True, will plot the errorbars above the plot
symbols. Default is below.

lolims, uplims, xlolims, xuplims : bool, default: False
lolims, uplims, xlolims, xuplims : bool or array-like, default: False
These arguments can be used to indicate that a value gives only
upper/lower limits. In that case a caret symbol is used to
indicate this. *lims*-arguments may be scalars, or array-likes of
Expand Down
12 changes: 6 additions & 6 deletions lib/matplotlib/axes/_axes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Axes(_AxesBase):
@overload
def legend(self) -> Legend: ...
@overload
def legend(self, handles: Sequence[Artist], labels: Sequence[str], **kwargs) -> Legend: ...
def legend(self, handles: Sequence[Artist | tuple[Artist, ...]], labels: Sequence[str], **kwargs) -> Legend: ...
@overload
def legend(self, *, handles: Sequence[Artist], **kwargs) -> Legend: ...
def legend(self, *, handles: Sequence[Artist | tuple[Artist, ...]], **kwargs) -> Legend: ...
@overload
def legend(self, labels: Sequence[str], **kwargs) -> Legend: ...
@overload
Expand Down Expand Up @@ -332,10 +332,10 @@ class Axes(_AxesBase):
elinewidth: float | None = ...,
capsize: float | None = ...,
barsabove: bool = ...,
lolims: bool = ...,
uplims: bool = ...,
xlolims: bool = ...,
xuplims: bool = ...,
lolims: bool | ArrayLike = ...,
uplims: bool | ArrayLike = ...,
xlolims: bool | ArrayLike = ...,
xuplims: bool | ArrayLike = ...,
errorevery: int | tuple[int, int] = ...,
capthick: float | None = ...,
*,
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def __init__(
parent : `~matplotlib.axes.Axes` or `.Figure`
The artist that contains the legend.

handles : list of `.Artist`
handles : list of (`.Artist` or tuple of `.Artist`)
A list of Artists (lines, patches) to be added to the legend.

labels : list of str
Expand Down Expand Up @@ -1322,7 +1322,7 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):

Returns
-------
handles : list of `.Artist`
handles : list of (`.Artist` or tuple of `.Artist`)
The legend handles.
labels : list of str
The legend labels.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/legend.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Legend(Artist):
def __init__(
self,
parent: Axes | Figure,
handles: Iterable[Artist],
handles: Iterable[Artist | tuple[Artist, ...]],
labels: Iterable[str],
*,
loc: str | tuple[float, float] | int | None = ...,
Expand Down
10 changes: 5 additions & 5 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ def figure(

for hookspecs in rcParams["figure.hooks"]:
module_name, dotted_name = hookspecs.split(":")
obj = importlib.import_module(module_name)
obj: Any = importlib.import_module(module_name)
for part in dotted_name.split("."):
obj = getattr(obj, part)
obj(fig)
Expand Down Expand Up @@ -2961,10 +2961,10 @@ def errorbar(
elinewidth: float | None = None,
capsize: float | None = None,
barsabove: bool = False,
lolims: bool = False,
uplims: bool = False,
xlolims: bool = False,
xuplims: bool = False,
lolims: bool | ArrayLike = False,
uplims: bool | ArrayLike = False,
xlolims: bool | ArrayLike = False,
xuplims: bool | ArrayLike = False,
errorevery: int | tuple[int, int] = 1,
capthick: float | None = None,
*,
Expand Down