Skip to content

Commit 56d4f69

Browse files
authored
Merge pull request #17749 from anntzer/custombboxtransmuter
Deprecate `FancyBboxPatch(..., boxstyle="custom", bbox_transmuter=...)`
2 parents 9205c23 + d50234c commit 56d4f69

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

doc/api/api_changes_3.4/deprecations.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ Deprecations
55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66
This parameter is considered internal and deprecated.
77

8+
89
Colorbar docstrings
910
~~~~~~~~~~~~~~~~~~~
1011
The following globals in :mod:`matplotlib.colorbar` are deprecated:
1112
``colorbar_doc``, ``colormap_kw_doc``, ``make_axes_kw_doc``.
13+
14+
``FancyBboxPatch(..., boxstyle="custom", bbox_transmuter=...)``
15+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
In order to use a custom boxstyle, directly pass it as the *boxstyle* argument
17+
to `.FancyBboxPatch`. This was previously already possible, and is consistent
18+
with custom arrow styles and connection styles.

lib/matplotlib/patches.py

Lines changed: 11 additions & 4 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", bbox_transmuter=None,
35693570
mutation_scale=1, mutation_aspect=1,
@@ -3616,6 +3617,10 @@ def __init__(self, xy, width, height,
36163617
self._height = height
36173618

36183619
if boxstyle == "custom":
3620+
cbook._warn_deprecated(
3621+
"3.4", message="Support for boxstyle='custom' is deprecated "
3622+
"since %(since)s and will be removed %(removal)s; directly "
3623+
"pass a boxstyle instance as the boxstyle parameter instead.")
36193624
if bbox_transmuter is None:
36203625
raise ValueError("bbox_transmuter argument is needed with "
36213626
"custom boxstyle")
@@ -3641,10 +3646,12 @@ def set_boxstyle(self, boxstyle=None, **kwargs):
36413646
36423647
Parameters
36433648
----------
3644-
boxstyle : str
3645-
The name of the box style. Optionally, followed by a comma and a
3646-
comma-separated list of attributes. The attributes may
3647-
alternatively be passed separately as keyword arguments.
3649+
boxstyle : str or `matplotlib.patches.BoxStyle`
3650+
The style of the fancy box. This can either be a `.BoxStyle`
3651+
instance or a string of the style name and optionally comma
3652+
seprarated attributes (e.g. "Round, pad=0.2"). This string is
3653+
passed to `.BoxStyle` to construct a `.BoxStyle` object. See
3654+
there for a full documentation.
36483655
36493656
The following box styles are available:
36503657

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)