Skip to content

Commit f7ff8dc

Browse files
committed
Deprecate parameter props of Shadow
1 parent d9ae387 commit f7ff8dc

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
@@ -211,3 +211,8 @@ The *clear_temp* parameter and attribute of `.FileMovieWriter` is
211211
deprecated. In the future, files placed in a temporary directory (using
212212
``frame_prefix=None``, the default) will be cleared; files placed elsewhere
213213
will not.
214+
215+
Passing *props* to `.Shadow`
216+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217+
The parameter *props* of `.Shadow` is deprecated. Use keyword arguments
218+
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
@@ -627,33 +627,51 @@ class Shadow(Patch):
627627
def __str__(self):
628628
return "Shadow(%s)" % (str(self.patch))
629629

630+
@cbook._delete_parameter("3.3", "props")
630631
@docstring.dedent_interpd
631632
def __init__(self, patch, ox, oy, props=None, **kwargs):
632633
"""
633-
Create a shadow of the given *patch* offset by *ox*, *oy*.
634-
*props*, if not *None*, is a patch property update dictionary.
635-
If *None*, the shadow will have have the same color as the face,
634+
Create a shadow of the given *patch*.
635+
636+
By default, the shadow will have the same face color as the *patch*,
636637
but darkened.
637638
638-
Valid keyword arguments are:
639+
Parameters
640+
----------
641+
patch : `.Patch`
642+
The patch to create the shadow for.
643+
ox, oy : float
644+
The shift of the shadow in data coordinates, scaled by a factor
645+
of dpi/72.
646+
props : dict
647+
*deprecated (use kwargs instead)* Properties of the shadow patch.
648+
**kwargs
649+
Properties of the shadow patch. Supported keys are:
639650
640-
%(Patch)s
651+
%(Patch)s
641652
"""
642653
Patch.__init__(self)
643654
self.patch = patch
644-
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}
645658
self._ox, self._oy = ox, oy
646659
self._shadow_transform = transforms.Affine2D()
647660
self._update()
648661

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

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy