Skip to content

Deprecate BboxBase.corners. #26878

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/deprecations/26878-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``BboxBase.corners``
~~~~~~~~~~~~~~~~~~~~
... is deprecated with no replacement.
9 changes: 6 additions & 3 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@
"""Construct a `Bbox` by translating this one by *tx* and *ty*."""
return Bbox(self._points + (tx, ty))

@_api.deprecated("3.9")
def corners(self):
"""
Return the corners of this rectangle as an array of points.
Expand All @@ -642,10 +643,12 @@
Return the axes-aligned bounding box that bounds the result of rotating
this `Bbox` by an angle of *radians*.
"""
corners = self.corners()
corners_rotated = Affine2D().rotate(radians).transform(corners)
(x0, y0), (x1, y1) = self.get_points()

Check warning on line 646 in lib/matplotlib/transforms.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/transforms.py#L646

Added line #L646 was not covered by tests
bbox = Bbox.unit()
bbox.update_from_data_xy(corners_rotated, ignore=True)
bbox.update_from_data_xy(

Check warning on line 648 in lib/matplotlib/transforms.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/transforms.py#L648

Added line #L648 was not covered by tests
Affine2D().rotate(radians).transform(
[[x0, y0], [x0, y1], [x1, y0], [x1, y1]]),
ignore=True)
return bbox

@staticmethod
Expand Down
Loading