Skip to content

Commit b44be42

Browse files
committed
Deprecate FancyBboxPatch(..., boxstyle="custom", bbox_transmuter=...)
One can directly pass the custom bbox as the `boxstyle` argument, instead of setting `boxstyle` to "custom" and passing it as the (otherwise unused) `bbox_transmuter` argument. This is consistent with arrowstyles and connectionstyles. The old API appears to date back to very early boxstyle API designs (pre-73f34bf), where arbitrary callables were not directly supported. In text.py one can just not pop `bbox_transmuter` from rectprops but just pass the dict as is to FancyBboxPatch, triggering the deprecation if and only if the key is present.
1 parent 0cf3974 commit b44be42

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
Deprecations
22
------------
3+
4+
``FancyBboxPatch(..., boxstyle="custom", bbox_transmuter=...)``
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
In order to use a custom boxsyle, directly pass it as the *boxstyle* argument
7+
to `.FancyBboxPatch`. This was previously already possible, and is consistent
8+
with custom arrow styles and connection styles.

lib/matplotlib/patches.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,6 +3564,7 @@ def __str__(self):
35643564
return s % (self._x, self._y, self._width, self._height)
35653565

35663566
@docstring.dedent_interpd
3567+
@cbook._delete_parameter("3.4", "bbox_transmuter", alternative="boxstyle")
35673568
def __init__(self, xy, width, height,
35683569
boxstyle="round",
35693570
bbox_transmuter=None,
@@ -3618,6 +3619,10 @@ def __init__(self, xy, width, height,
36183619
self._height = height
36193620

36203621
if boxstyle == "custom":
3622+
cbook._warn_deprecated(
3623+
"3.4", message="Support for boxstyle='custom' is deprecated "
3624+
"since %(since)s and will be removed %(removal)s; directly "
3625+
"pass a boxstyle instance as the boxstyle parameter instead.")
36213626
if bbox_transmuter is None:
36223627
raise ValueError("bbox_transmuter argument is needed with "
36233628
"custom boxstyle")

lib/matplotlib/text.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,20 +449,12 @@ def set_bbox(self, rectprops):
449449
else:
450450
if pad is None:
451451
pad = 0.3
452-
453452
# boxstyle could be a callable or a string
454453
if isinstance(boxstyle, str) and "pad" not in boxstyle:
455454
boxstyle += ",pad=%0.2f" % pad
456-
457-
bbox_transmuter = props.pop("bbox_transmuter", None)
458-
459455
self._bbox_patch = FancyBboxPatch(
460-
(0., 0.),
461-
1., 1.,
462-
boxstyle=boxstyle,
463-
bbox_transmuter=bbox_transmuter,
464-
transform=IdentityTransform(),
465-
**props)
456+
(0, 0), 1, 1,
457+
boxstyle=boxstyle, transform=IdentityTransform(), **props)
466458
else:
467459
self._bbox_patch = None
468460

0 commit comments

Comments
 (0)