Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cleaned up the span_where class method from Polycollections. #26874

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion ci/mypy-stubtest-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/api/artist_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/removals/26874-AG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``collections.PolyCollection.span_where`` and ``collections.BrokenBarHCollection``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... removed as it was deprecated during 3.7. Use ``fill_between`` instead
2 changes: 1 addition & 1 deletion doc/users/prev_whats_new/whats_new_1.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be removed from old docs, even though it doesn't exist any more, because it's a historical reflection of "what's new in 1.4". Mark it as code style instead:

Suggested change
:class:`~matplotlib.collections.BrokenBarHCollection`
``matplotlib.collections.BrokenBarHCollection``

``matplotlib.collections.BrokenBarHCollection``
:class:`~matplotlib.collections.CircleCollection`
:class:`~matplotlib.collections.PathCollection`
:class:`~matplotlib.collections.PolyCollection`
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/axes/_axes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ from matplotlib.backend_bases import RendererBase
from matplotlib.collections import (
Collection,
LineCollection,
BrokenBarHCollection,
PathCollection,
PolyCollection,
EventCollection,
Expand Down Expand Up @@ -282,7 +281,7 @@ class Axes(_AxesBase):
*,
data=...,
**kwargs
) -> BrokenBarHCollection: ...
) -> PolyCollection: ...
def stem(
self,
*args: ArrayLike | str,
Expand Down
45 changes: 0 additions & 45 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
12 changes: 0 additions & 12 deletions lib/matplotlib/collections.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
from matplotlib.collections import (
Collection,
LineCollection,
BrokenBarHCollection,
PolyCollection,
PathCollection,
EventCollection,
Expand Down Expand Up @@ -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
)
Expand Down