Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[TYP] Add overload ofpyplot.subplots#27001

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ksunden merged 6 commits intomatplotlib:mainfromn-takumasa:fix-subplots-typing
May 30, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
34 changes: 24 additions & 10 deletionslib/matplotlib/figure.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
from collections.abc import Callable, Hashable, Iterable
import os
from typing import Any, IO, Literal, TypeVar, overload
from typing import Any, IO, Literal,Sequence,TypeVar, overload

import numpy as np
from numpy.typing import ArrayLike

from matplotlib.artist import Artist
from matplotlib.axes import Axes, SubplotBase
from matplotlib.axes import Axes
from matplotlib.backend_bases import (
FigureCanvasBase,
MouseButton,
Expand DownExpand Up@@ -92,6 +92,20 @@ class FigureBase(Artist):
@overload
def add_subplot(self, **kwargs) -> Axes: ...
@overload
def subplots(
self,
nrows: Literal[1] = ...,
ncols: Literal[1] = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[True] = ...,
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
) -> Axes: ...
@overload
def subplots(
self,
nrows: int = ...,
Expand All@@ -100,11 +114,11 @@ class FigureBase(Artist):
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[False],
width_ratios:ArrayLike | None = ...,
height_ratios:ArrayLike | None = ...,
width_ratios:Sequence[float] | None = ...,
height_ratios:Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...
) -> np.ndarray: ...
gridspec_kw: dict[str, Any] | None = ...,
) -> np.ndarray: ... # TODO numpy/numpy#24738
@overload
def subplots(
self,
Expand All@@ -114,11 +128,11 @@ class FigureBase(Artist):
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: bool = ...,
width_ratios:ArrayLike | None = ...,
height_ratios:ArrayLike | None = ...,
width_ratios:Sequence[float] | None = ...,
height_ratios:Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...
) ->np.ndarray |SubplotBase | Axes: ...
gridspec_kw: dict[str, Any] | None = ...,
) ->Axes |np.ndarray: ...
def delaxes(self, ax: Axes) -> None: ...
def clear(self, keep_observers: bool = ...) -> None: ...
def clf(self, keep_observers: bool = ...) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/gridspec.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ class GridSpecBase:
sharey: bool | Literal["all", "row", "col", "none"] = ...,
squeeze: Literal[True] = ...,
subplot_kw: dict[str, Any] | None = ...
) -> np.ndarray |SubplotBase |Axes: ...
) -> np.ndarray | Axes: ...

class GridSpec(GridSpecBase):
left: float | None
Expand Down
51 changes: 51 additions & 0 deletionslib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1440,6 +1440,57 @@ def subplot(*args, **kwargs) -> Axes:
return ax


@overload
def subplots(
nrows: Literal[1] = ...,
ncols: Literal[1] = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[True] = ...,
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
**fig_kw
) -> tuple[Figure, Axes]:
...


@overload
def subplots(
nrows: int = ...,
ncols: int = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[False],
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
**fig_kw
) -> tuple[Figure, np.ndarray]: # TODO numpy/numpy#24738
...


@overload
def subplots(
nrows: int = ...,
ncols: int = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: bool = ...,
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
**fig_kw
) -> tuple[Figure, Axes | np.ndarray]:
...


def subplots(
nrows: int = 1, ncols: int = 1, *,
sharex: bool | Literal["none", "all", "row", "col"] = False,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp