Skip to content

Commit 7b0cfe4

Browse files
authored
Merge pull request #16098 from timhoffm/fix-tick
Deprecate parameter props of Shadow
2 parents 2ff579d + 72da9bf commit 7b0cfe4

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
@@ -120,6 +120,11 @@ The following parameters do not have any effect and are deprecated:
120120
- parameter *s* of `.AnnotationBbox.get_fontsize()`
121121
- parameter *label* of `.Tick`
122122

123+
Passing *props* to `.Shadow`
124+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125+
The parameter *props* of `.Shadow` is deprecated. Use keyword arguments
126+
instead.
127+
123128
``Axes.update_datalim_bounds``
124129
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125130
This method is deprecated. Use

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
@@ -624,33 +624,51 @@ class Shadow(Patch):
624624
def __str__(self):
625625
return "Shadow(%s)" % (str(self.patch))
626626

627+
@cbook._delete_parameter("3.3", "props")
627628
@docstring.dedent_interpd
628629
def __init__(self, patch, ox, oy, props=None, **kwargs):
629630
"""
630-
Create a shadow of the given *patch* offset by *ox*, *oy*.
631-
*props*, if not *None*, is a patch property update dictionary.
632-
If *None*, the shadow will have have the same color as the face,
631+
Create a shadow of the given *patch*.
632+
633+
By default, the shadow will have the same face color as the *patch*,
633634
but darkened.
634635
635-
Valid keyword arguments are:
636+
Parameters
637+
----------
638+
patch : `.Patch`
639+
The patch to create the shadow for.
640+
ox, oy : float
641+
The shift of the shadow in data coordinates, scaled by a factor
642+
of dpi/72.
643+
props : dict
644+
*deprecated (use kwargs instead)* Properties of the shadow patch.
645+
**kwargs
646+
Properties of the shadow patch. Supported keys are:
636647
637-
%(Patch)s
648+
%(Patch)s
638649
"""
639650
Patch.__init__(self)
640651
self.patch = patch
641-
self.props = props
652+
# Note: when removing props, we can directly pass kwargs to _update()
653+
# and remove self._props
654+
self._props = {**(props if props is not None else {}), **kwargs}
642655
self._ox, self._oy = ox, oy
643656
self._shadow_transform = transforms.Affine2D()
644657
self._update()
645658

659+
@cbook.deprecated("3.3")
660+
@property
661+
def props(self):
662+
return self._props
663+
646664
def _update(self):
647665
self.update_from(self.patch)
648666

649667
# Place the shadow patch directly behind the inherited patch.
650668
self.set_zorder(np.nextafter(self.patch.zorder, -np.inf))
651669

652-
if self.props is not None:
653-
self.update(self.props)
670+
if self._props:
671+
self.update(self._props)
654672
else:
655673
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
656674
self.set_facecolor(color)

0 commit comments

Comments
 (0)