From 74af1bbb2bf36092ef7edf1a2850face9bb06b24 Mon Sep 17 00:00:00 2001 From: DerWeh Date: Wed, 29 Jan 2025 22:03:16 +0100 Subject: [PATCH 1/2] DOC: correctly specify return type of `figaspect` --- lib/matplotlib/figure.py | 4 ++-- lib/matplotlib/figure.pyi | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 76b2df563ade..759e9f22dc9b 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -3655,8 +3655,8 @@ def figaspect(arg): Returns ------- - width, height : float - The figure size in inches. + size : (2,) array + The width and height of the figure in inches. Notes ----- diff --git a/lib/matplotlib/figure.pyi b/lib/matplotlib/figure.pyi index 08bf1505532b..064503c91384 100644 --- a/lib/matplotlib/figure.pyi +++ b/lib/matplotlib/figure.pyi @@ -418,4 +418,6 @@ class Figure(FigureBase): rect: tuple[float, float, float, float] | None = ... ) -> None: ... -def figaspect(arg: float | ArrayLike) -> tuple[float, float]: ... +def figaspect( + arg: float | ArrayLike, +) -> np.ndarray[tuple[Literal[2]], np.dtype[np.float64]]: ... From 59b6d9cd2e1caa41cd9274ed2394a5176c7d77b3 Mon Sep 17 00:00:00 2001 From: Weh Andreas Date: Mon, 3 Feb 2025 11:23:11 +0100 Subject: [PATCH 2/2] TYP: relax type hints for figure's figsize --- lib/matplotlib/pyplot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 43c4ac70bff0..3068185d2cc8 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -876,7 +876,7 @@ def figure( # autoincrement if None, else integer from 1-N num: int | str | Figure | SubFigure | None = None, # defaults to rc figure.figsize - figsize: tuple[float, float] | None = None, + figsize: ArrayLike | None = None, # defaults to rc figure.dpi dpi: float | None = None, *,