Skip to content

Commit 9792aab

Browse files
committed
Deprecate Bbox.anchored() with no container.
This previously returned a copy of the bbox itself, and was completely unused; let's deprecate this for clarity ("anchoring a bbox to itself" doesn't make much sense anyways).
1 parent 7bc69f2 commit 9792aab

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
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

+6-6
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)