Skip to content

Commit ff8eaa2

Browse files
committed
Deprecate parameter props of Shadow
1 parent bc04c8a commit ff8eaa2

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,8 @@ Likewise, passing the *alpha*, *boundaries*, *values*, *extend*, or *filled*
106106
parameters with a `.ContourSet` mappable, or the *alpha* parameter with an
107107
`.Artist` mappable, is deprecated, as the mappable would likewise override
108108
them.
109+
110+
Passing *props* to `.Shadow`
111+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112+
The parameter *props* of `.Shadow` is deprecated. Use keyword arguments
113+
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: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -628,33 +628,50 @@ 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 points.
646+
props : dict
647+
*deprecated (use kwargs instead)* Properties of the shadow patch.
648+
**kwargs
649+
Properties of the shadow patch. Supported keys are:
640650
641-
%(Patch)s
651+
%(Patch)s
642652
"""
643653
Patch.__init__(self)
644654
self.patch = patch
645-
self.props = props
655+
# Note: when removing props, we can directly pass kwargs to _update()
656+
# and remove self._props
657+
self._props = {**(props if props is not None else {}), **kwargs}
646658
self._ox, self._oy = ox, oy
647659
self._shadow_transform = transforms.Affine2D()
648660
self._update()
649661

662+
@cbook.deprecated("3.3")
663+
@property
664+
def props(self):
665+
return self._props
666+
650667
def _update(self):
651668
self.update_from(self.patch)
652669

653670
# Place the shadow patch directly behind the inherited patch.
654671
self.set_zorder(np.nextafter(self.patch.zorder, -np.inf))
655672

656-
if self.props is not None:
657-
self.update(self.props)
673+
if self._props:
674+
self.update(self._props)
658675
else:
659676
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
660677
self.set_facecolor(color)

0 commit comments

Comments
 (0)