From 3f72eca907dbe6ebedd4e4437139ee6393b12947 Mon Sep 17 00:00:00 2001 From: Aditi Gautam Date: Fri, 22 Sep 2023 11:34:20 -0700 Subject: [PATCH] Cleaned up the span_where class method from Polycollections. --- ci/mypy-stubtest-allowlist.txt | 1 - doc/api/artist_api.rst | 2 +- .../next_api_changes/removals/26874-AG.rst | 4 ++ doc/users/prev_whats_new/whats_new_1.4.rst | 2 +- lib/matplotlib/axes/_axes.pyi | 3 +- lib/matplotlib/collections.py | 45 ------------------- lib/matplotlib/collections.pyi | 12 ----- lib/matplotlib/pyplot.py | 3 +- 8 files changed, 8 insertions(+), 64 deletions(-) create mode 100644 doc/api/next_api_changes/removals/26874-AG.rst diff --git a/ci/mypy-stubtest-allowlist.txt b/ci/mypy-stubtest-allowlist.txt index e0890b3f7117..78f269a5f5bf 100644 --- a/ci/mypy-stubtest-allowlist.txt +++ b/ci/mypy-stubtest-allowlist.txt @@ -52,7 +52,6 @@ matplotlib.figure.Figure.set_tight_layout # 3.7 deprecations matplotlib.cm.register_cmap matplotlib.cm.unregister_cmap -matplotlib.collections.PolyCollection.span_where # 3.8 deprecations matplotlib.cbook.get_sample_data diff --git a/doc/api/artist_api.rst b/doc/api/artist_api.rst index 3903bbd5924d..df7a6e8b1c04 100644 --- a/doc/api/artist_api.rst +++ b/doc/api/artist_api.rst @@ -11,7 +11,7 @@ Inheritance Diagrams ==================== -.. inheritance-diagram:: matplotlib.axes._axes.Axes matplotlib.axes._base._AxesBase matplotlib.axis.Axis matplotlib.axis.Tick matplotlib.axis.XAxis matplotlib.axis.XTick matplotlib.axis.YAxis matplotlib.axis.YTick matplotlib.collections.AsteriskPolygonCollection matplotlib.collections.BrokenBarHCollection matplotlib.collections.CircleCollection matplotlib.collections.Collection matplotlib.collections.EllipseCollection matplotlib.collections.EventCollection matplotlib.collections.LineCollection matplotlib.collections.PatchCollection matplotlib.collections.PathCollection matplotlib.collections.PolyCollection matplotlib.collections.QuadMesh matplotlib.collections.RegularPolyCollection matplotlib.collections.StarPolygonCollection matplotlib.collections.TriMesh matplotlib.collections._CollectionWithSizes matplotlib.contour.ClabelText matplotlib.contour.ContourSet matplotlib.contour.QuadContourSet matplotlib.figure.FigureBase matplotlib.figure.Figure matplotlib.figure.SubFigure matplotlib.image.AxesImage matplotlib.image.BboxImage matplotlib.image.FigureImage matplotlib.image.NonUniformImage matplotlib.image.PcolorImage matplotlib.image._ImageBase matplotlib.legend.Legend matplotlib.lines.Line2D matplotlib.offsetbox.AnchoredOffsetbox matplotlib.offsetbox.AnchoredText matplotlib.offsetbox.AnnotationBbox matplotlib.offsetbox.AuxTransformBox matplotlib.offsetbox.DrawingArea matplotlib.offsetbox.HPacker matplotlib.offsetbox.OffsetBox matplotlib.offsetbox.OffsetImage matplotlib.offsetbox.PackerBase matplotlib.offsetbox.PaddedBox matplotlib.offsetbox.TextArea matplotlib.offsetbox.VPacker matplotlib.patches.Annulus matplotlib.patches.Arc matplotlib.patches.Arrow matplotlib.patches.Circle matplotlib.patches.CirclePolygon matplotlib.patches.ConnectionPatch matplotlib.patches.Ellipse matplotlib.patches.FancyArrow matplotlib.patches.FancyArrowPatch matplotlib.patches.FancyBboxPatch matplotlib.patches.Patch matplotlib.patches.PathPatch matplotlib.patches.Polygon matplotlib.patches.Rectangle matplotlib.patches.RegularPolygon matplotlib.patches.Shadow matplotlib.patches.StepPatch matplotlib.patches.Wedge matplotlib.projections.geo.AitoffAxes matplotlib.projections.geo.GeoAxes matplotlib.projections.geo.HammerAxes matplotlib.projections.geo.LambertAxes matplotlib.projections.geo.MollweideAxes matplotlib.projections.polar.PolarAxes matplotlib.projections.polar.RadialAxis matplotlib.projections.polar.RadialTick matplotlib.projections.polar.ThetaAxis matplotlib.projections.polar.ThetaTick matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text matplotlib.tri.TriContourSet +.. inheritance-diagram:: matplotlib.axes._axes.Axes matplotlib.axes._base._AxesBase matplotlib.axis.Axis matplotlib.axis.Tick matplotlib.axis.XAxis matplotlib.axis.XTick matplotlib.axis.YAxis matplotlib.axis.YTick matplotlib.collections.AsteriskPolygonCollection matplotlib.collections.CircleCollection matplotlib.collections.Collection matplotlib.collections.EllipseCollection matplotlib.collections.EventCollection matplotlib.collections.LineCollection matplotlib.collections.PatchCollection matplotlib.collections.PathCollection matplotlib.collections.PolyCollection matplotlib.collections.QuadMesh matplotlib.collections.RegularPolyCollection matplotlib.collections.StarPolygonCollection matplotlib.collections.TriMesh matplotlib.collections._CollectionWithSizes matplotlib.contour.ClabelText matplotlib.contour.ContourSet matplotlib.contour.QuadContourSet matplotlib.figure.FigureBase matplotlib.figure.Figure matplotlib.figure.SubFigure matplotlib.image.AxesImage matplotlib.image.BboxImage matplotlib.image.FigureImage matplotlib.image.NonUniformImage matplotlib.image.PcolorImage matplotlib.image._ImageBase matplotlib.legend.Legend matplotlib.lines.Line2D matplotlib.offsetbox.AnchoredOffsetbox matplotlib.offsetbox.AnchoredText matplotlib.offsetbox.AnnotationBbox matplotlib.offsetbox.AuxTransformBox matplotlib.offsetbox.DrawingArea matplotlib.offsetbox.HPacker matplotlib.offsetbox.OffsetBox matplotlib.offsetbox.OffsetImage matplotlib.offsetbox.PackerBase matplotlib.offsetbox.PaddedBox matplotlib.offsetbox.TextArea matplotlib.offsetbox.VPacker matplotlib.patches.Annulus matplotlib.patches.Arc matplotlib.patches.Arrow matplotlib.patches.Circle matplotlib.patches.CirclePolygon matplotlib.patches.ConnectionPatch matplotlib.patches.Ellipse matplotlib.patches.FancyArrow matplotlib.patches.FancyArrowPatch matplotlib.patches.FancyBboxPatch matplotlib.patches.Patch matplotlib.patches.PathPatch matplotlib.patches.Polygon matplotlib.patches.Rectangle matplotlib.patches.RegularPolygon matplotlib.patches.Shadow matplotlib.patches.StepPatch matplotlib.patches.Wedge matplotlib.projections.geo.AitoffAxes matplotlib.projections.geo.GeoAxes matplotlib.projections.geo.HammerAxes matplotlib.projections.geo.LambertAxes matplotlib.projections.geo.MollweideAxes matplotlib.projections.polar.PolarAxes matplotlib.projections.polar.RadialAxis matplotlib.projections.polar.RadialTick matplotlib.projections.polar.ThetaAxis matplotlib.projections.polar.ThetaTick matplotlib.quiver.Barbs matplotlib.quiver.Quiver matplotlib.quiver.QuiverKey matplotlib.spines.Spine matplotlib.table.Cell matplotlib.table.Table matplotlib.text.Annotation matplotlib.text.Text matplotlib.tri.TriContourSet :parts: 1 :private-bases: diff --git a/doc/api/next_api_changes/removals/26874-AG.rst b/doc/api/next_api_changes/removals/26874-AG.rst new file mode 100644 index 000000000000..ad305cf9d96c --- /dev/null +++ b/doc/api/next_api_changes/removals/26874-AG.rst @@ -0,0 +1,4 @@ +``collections.PolyCollection.span_where`` and ``collections.BrokenBarHCollection`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +... removed as it was deprecated during 3.7. Use ``fill_between`` instead diff --git a/doc/users/prev_whats_new/whats_new_1.4.rst b/doc/users/prev_whats_new/whats_new_1.4.rst index 39eefa81b168..eb0e93fd8883 100644 --- a/doc/users/prev_whats_new/whats_new_1.4.rst +++ b/doc/users/prev_whats_new/whats_new_1.4.rst @@ -221,7 +221,7 @@ Added size related functions to specialized `.Collection`\s Added the ``get_size`` and ``set_size`` functions to control the size of elements of specialized collections ( :class:`~matplotlib.collections.AsteriskPolygonCollection` -:class:`~matplotlib.collections.BrokenBarHCollection` +``matplotlib.collections.BrokenBarHCollection`` :class:`~matplotlib.collections.CircleCollection` :class:`~matplotlib.collections.PathCollection` :class:`~matplotlib.collections.PolyCollection` diff --git a/lib/matplotlib/axes/_axes.pyi b/lib/matplotlib/axes/_axes.pyi index 96ea087f7eb9..5dff356be4a9 100644 --- a/lib/matplotlib/axes/_axes.pyi +++ b/lib/matplotlib/axes/_axes.pyi @@ -6,7 +6,6 @@ from matplotlib.backend_bases import RendererBase from matplotlib.collections import ( Collection, LineCollection, - BrokenBarHCollection, PathCollection, PolyCollection, EventCollection, @@ -282,7 +281,7 @@ class Axes(_AxesBase): *, data=..., **kwargs - ) -> BrokenBarHCollection: ... + ) -> PolyCollection: ... def stem( self, *args: ArrayLike | str, diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 81db24d0c026..cc20e5cebc1b 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -1253,51 +1253,6 @@ def set_verts_and_codes(self, verts, codes): for xy, cds in zip(verts, codes)] self.stale = True - @classmethod - @_api.deprecated("3.7", alternative="fill_between") - def span_where(cls, x, ymin, ymax, where, **kwargs): - """ - Return a `.BrokenBarHCollection` that plots horizontal bars from - over the regions in *x* where *where* is True. The bars range - on the y-axis from *ymin* to *ymax* - - *kwargs* are passed on to the collection. - """ - xranges = [] - for ind0, ind1 in cbook.contiguous_regions(where): - xslice = x[ind0:ind1] - if not len(xslice): - continue - xranges.append((xslice[0], xslice[-1] - xslice[0])) - return BrokenBarHCollection(xranges, [ymin, ymax - ymin], **kwargs) - - -@_api.deprecated("3.7") -class BrokenBarHCollection(PolyCollection): - """ - A collection of horizontal bars spanning *yrange* with a sequence of - *xranges*. - """ - def __init__(self, xranges, yrange, **kwargs): - """ - Parameters - ---------- - xranges : list of (float, float) - The sequence of (left-edge-position, width) pairs for each bar. - yrange : (float, float) - The (lower-edge, height) common to all bars. - **kwargs - Forwarded to `.Collection`. - """ - ymin, ywidth = yrange - ymax = ymin + ywidth - verts = [[(xmin, ymin), - (xmin, ymax), - (xmin + xwidth, ymax), - (xmin + xwidth, ymin), - (xmin, ymin)] for xmin, xwidth in xranges] - super().__init__(verts, **kwargs) - class RegularPolyCollection(_CollectionWithSizes): """A collection of n-sided regular polygons.""" diff --git a/lib/matplotlib/collections.pyi b/lib/matplotlib/collections.pyi index 01682a55b374..7162c4687dfa 100644 --- a/lib/matplotlib/collections.pyi +++ b/lib/matplotlib/collections.pyi @@ -106,18 +106,6 @@ class PolyCollection(_CollectionWithSizes): self, verts: Sequence[ArrayLike | Path], codes: Sequence[int] ) -> None: ... -class BrokenBarHCollection(PolyCollection): - def __init__( - self, - xranges: Iterable[tuple[float, float]], - yrange: tuple[float, float], - **kwargs - ) -> None: ... - @classmethod - def span_where( - cls, x: ArrayLike, ymin: float, ymax: float, where: ArrayLike, **kwargs - ) -> BrokenBarHCollection: ... - class RegularPolyCollection(_CollectionWithSizes): def __init__( self, numsides: int, *, rotation: float = ..., sizes: ArrayLike = ..., **kwargs diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 74a73725d5d9..d5c100089993 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -99,7 +99,6 @@ from matplotlib.collections import ( Collection, LineCollection, - BrokenBarHCollection, PolyCollection, PathCollection, EventCollection, @@ -2873,7 +2872,7 @@ def broken_barh( *, data=None, **kwargs, -) -> BrokenBarHCollection: +) -> PolyCollection: return gca().broken_barh( xranges, yrange, **({"data": data} if data is not None else {}), **kwargs )