Skip to content

Commit 5cda312

Browse files
committed
feat: improve plt.figure
1 parent e787b67 commit 5cda312

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/matplotlib-stubs/pyplot.pyi

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import datetime
2+
import os
23
from collections.abc import Callable, Sequence
3-
from pathlib import Path
4-
from typing import Any, BinaryIO, ContextManager, Literal, overload, Unpack
4+
from typing import Any, ContextManager, IO, Literal, overload, Unpack
55

66
import numpy as np
77
import numpy.typing as npt
88
from matplotlib import rcParams as rcParams
99
from matplotlib._typing import ArrayLike, Color, FileLike, Line2DProperty, PathCollectionProperties, PathLike, Scalar
1010
from matplotlib.colorizer import Colorizer
1111
from matplotlib.contour import QuadContourSet
12+
from matplotlib.layout_engine import LayoutEngine
13+
from matplotlib.typing import ColorType
1214
from typing_extensions import Self
1315

1416
from .artist import Artist
@@ -78,14 +80,16 @@ class _xkcd:
7880

7981
def figure(
8082
num: int | str | Figure | SubFigure | None = None,
81-
figsize: Sequence[float] | None = None,
83+
figsize: ArrayLike | tuple[float, float, Literal["in", "cm", "px"]] | None = None,
8284
dpi: float | None = None,
83-
facecolor: Color | None = None,
84-
edgecolor: Color | None = None,
85+
*,
86+
facecolor: ColorType | None = None,
87+
edgecolor: ColorType | None = None,
8588
frameon: bool = True,
86-
FigureClass=...,
89+
FigureClass: type[Figure] = ...,
8790
clear: bool = False,
88-
**kwargs,
91+
layout: Literal["constrained", "compressed", "tight", "none"] | LayoutEngine | None = None,
92+
**kwargs: Any,
8993
) -> Figure: ...
9094
def gcf() -> Figure: ...
9195
def fignum_exists(num) -> bool: ...
@@ -94,11 +98,11 @@ def get_figlabels(): ...
9498
def get_current_fig_manager() -> FigureManagerBase: ...
9599
def connect(s: str, func: Callable): ...
96100
def disconnect(cid: int): ...
97-
def close(fig: None | int | str | Figure = ...) -> None: ...
101+
def close(fig: None | int | str | Figure | Literal["all"] = None) -> None: ...
98102
def clf() -> None: ...
99103
def draw() -> None: ...
100104
def savefig(
101-
fname: str | Path | BinaryIO,
105+
fname: str | os.PathLike | IO,
102106
*,
103107
transparent: bool | None = None,
104108
dpi: float | Literal["figure"] = "figure",

0 commit comments

Comments
 (0)