Skip to content

Commit 1afa73c

Browse files
committed
Deprecate parameter props of Shadow
1 parent 3d3c930 commit 1afa73c

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ them.
110110
``args_key`` and ``exec_key`` attributes of builtin `.MovieWriter`\s
111111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112112
These attributes are deprecated.
113+
114+
Passing *props* to `.Shadow`
115+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116+
The parameter *props* of `.Shadow` is deprecated. Use keyword arguments
117+
instead.

examples/text_labels_and_annotations/demo_text_path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def draw(self, renderer=None):
116116
text_patch = PathClippedImagePatch(text_path, arr, ec="none",
117117
transform=IdentityTransform())
118118

119-
shadow1 = Shadow(text_patch, 1, -1, props=dict(fc="none", ec="0.6", lw=3))
120-
shadow2 = Shadow(text_patch, 1, -1, props=dict(fc="0.3", ec="none"))
119+
shadow1 = Shadow(text_patch, 1, -1, fc="none", ec="0.6", lw=3)
120+
shadow2 = Shadow(text_patch, 1, -1, fc="0.3", ec="none")
121121

122122
# make offset box
123123
offsetbox = AuxTransformBox(IdentityTransform())

lib/matplotlib/patches.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -628,33 +628,51 @@ class Shadow(Patch):
628628
def __str__(self):
629629
return "Shadow(%s)" % (str(self.patch))
630630

631+
@cbook._delete_parameter("3.3", "props")
631632
@docstring.dedent_interpd
632633
def __init__(self, patch, ox, oy, props=None, **kwargs):
633634
"""
634-
Create a shadow of the given *patch* offset by *ox*, *oy*.
635-
*props*, if not *None*, is a patch property update dictionary.
636-
If *None*, the shadow will have have the same color as the face,
635+
Create a shadow of the given *patch*.
636+
637+
By default, the shadow will have the same face color as the *patch*,
637638
but darkened.
638639
639-
Valid keyword arguments are:
640+
Parameters
641+
----------
642+
patch : `.Patch`
643+
The patch to create the shadow for.
644+
ox, oy : float
645+
The shift of the shadow in data coordinates, scaled by a factor
646+
of dpi/72.
647+
props : dict
648+
*deprecated (use kwargs instead)* Properties of the shadow patch.
649+
**kwargs
650+
Properties of the shadow patch. Supported keys are:
640651
641-
%(Patch)s
652+
%(Patch)s
642653
"""
643654
Patch.__init__(self)
644655
self.patch = patch
645-
self.props = props
656+
# Note: when removing props, we can directly pass kwargs to _update()
657+
# and remove self._props
658+
self._props = {**(props if props is not None else {}), **kwargs}
646659
self._ox, self._oy = ox, oy
647660
self._shadow_transform = transforms.Affine2D()
648661
self._update()
649662

663+
@cbook.deprecated("3.3")
664+
@property
665+
def props(self):
666+
return self._props
667+
650668
def _update(self):
651669
self.update_from(self.patch)
652670

653671
# Place the shadow patch directly behind the inherited patch.
654672
self.set_zorder(np.nextafter(self.patch.zorder, -np.inf))
655673

656-
if self.props is not None:
657-
self.update(self.props)
674+
if self._props:
675+
self.update(self._props)
658676
else:
659677
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
660678
self.set_facecolor(color)

0 commit comments

Comments
 (0)