Skip to content

Commit 41fb34d

Browse files
authored
Merge pull request #24913 from anntzer/anc
Deprecate Bbox.anchored() with no container.
2 parents 9a0b72a + 9792aab commit 41fb34d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``bbox.anchored()`` with no explicit container
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Not passing a *container* argument to `.BboxBase.anchored` is now deprecated.

lib/matplotlib/transforms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,21 +501,21 @@ def anchored(self, c, container=None):
501501
bottom, 1 is right or top), 'C' (center), or a cardinal direction
502502
('SW', southwest, is bottom left, etc.).
503503
container : `Bbox`, optional
504-
The box within which the `Bbox` is positioned; it defaults
505-
to the initial `Bbox`.
504+
The box within which the `Bbox` is positioned.
506505
507506
See Also
508507
--------
509508
.Axes.set_anchor
510509
"""
511510
if container is None:
511+
_api.warn_deprecated(
512+
"3.8", message="Calling anchored() with no container bbox "
513+
"returns a frozen copy of the original bbox and is deprecated "
514+
"since %(since)s.")
512515
container = self
513516
l, b, w, h = container.bounds
514-
if isinstance(c, str):
515-
cx, cy = self.coefs[c]
516-
else:
517-
cx, cy = c
518517
L, B, W, H = self.bounds
518+
cx, cy = self.coefs[c] if isinstance(c, str) else c
519519
return Bbox(self._points +
520520
[(l + cx * (w - W)) - L,
521521
(b + cy * (h - H)) - B])

0 commit comments

Comments
 (0)