From 5112ad5c4ecb073b0a59fb75f39d79c7d75121ec Mon Sep 17 00:00:00 2001 From: Christian Mattsson <47303717+chrille0313@users.noreply.github.com> Date: Wed, 19 Jun 2024 14:20:31 +0000 Subject: [PATCH 1/2] docs: update return value for Axes.axhspan and Axes.axvspan --- lib/matplotlib/axes/_axes.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9a2b367fb502..b8ad2acab711 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1006,14 +1006,14 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs): Returns ------- - `~matplotlib.patches.Polygon` + `~matplotlib.patches.Rectangle` Horizontal span (rectangle) from (xmin, ymin) to (xmax, ymax). Other Parameters ---------------- - **kwargs : `~matplotlib.patches.Polygon` properties + **kwargs : `~matplotlib.patches.Rectangle` properties - %(Polygon:kwdoc)s + %(Rectangle:kwdoc)s See Also -------- @@ -1061,14 +1061,14 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs): Returns ------- - `~matplotlib.patches.Polygon` + `~matplotlib.patches.Rectangle` Vertical span (rectangle) from (xmin, ymin) to (xmax, ymax). Other Parameters ---------------- - **kwargs : `~matplotlib.patches.Polygon` properties + **kwargs : `~matplotlib.patches.Rectangle` properties - %(Polygon:kwdoc)s + %(Rectangle:kwdoc)s See Also -------- From f0aaec946e3bc243e4710ed6ceaa23d48ac9065c Mon Sep 17 00:00:00 2001 From: Christian Mattsson <47303717+chrille0313@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:26:44 +0000 Subject: [PATCH 2/2] update return type of Axes.axhspan and Axes.axvspan in interface --- lib/matplotlib/axes/_axes.pyi | 4 ++-- lib/matplotlib/pyplot.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes/_axes.pyi b/lib/matplotlib/axes/_axes.pyi index b728d24d9fe9..d04e3ad99ddc 100644 --- a/lib/matplotlib/axes/_axes.pyi +++ b/lib/matplotlib/axes/_axes.pyi @@ -155,10 +155,10 @@ class Axes(_AxesBase): ) -> AxLine: ... def axhspan( self, ymin: float, ymax: float, xmin: float = ..., xmax: float = ..., **kwargs - ) -> Polygon: ... + ) -> Rectangle: ... def axvspan( self, xmin: float, xmax: float, ymin: float = ..., ymax: float = ..., **kwargs - ) -> Polygon: ... + ) -> Rectangle: ... def hlines( self, y: float | ArrayLike, diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 9b516d5aae8a..6f02e55de23a 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2882,7 +2882,7 @@ def axhline(y: float = 0, xmin: float = 0, xmax: float = 1, **kwargs) -> Line2D: @_copy_docstring_and_deprecators(Axes.axhspan) def axhspan( ymin: float, ymax: float, xmin: float = 0, xmax: float = 1, **kwargs -) -> Polygon: +) -> Rectangle: return gca().axhspan(ymin, ymax, xmin=xmin, xmax=xmax, **kwargs) @@ -2920,7 +2920,7 @@ def axvline(x: float = 0, ymin: float = 0, ymax: float = 1, **kwargs) -> Line2D: @_copy_docstring_and_deprecators(Axes.axvspan) def axvspan( xmin: float, xmax: float, ymin: float = 0, ymax: float = 1, **kwargs -) -> Polygon: +) -> Rectangle: return gca().axvspan(xmin, xmax, ymin=ymin, ymax=ymax, **kwargs)