Skip to content

Deprecate parameter props of Shadow #16098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ The following parameters do not have any effect and are deprecated:
- parameter *s* of `.AnnotationBbox.get_fontsize()`
- parameter *label* of `.Tick`

Passing *props* to `.Shadow`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The parameter *props* of `.Shadow` is deprecated. Use keyword arguments
instead.

``Axes.update_datalim_bounds``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This method is deprecated. Use
Expand Down
4 changes: 2 additions & 2 deletions examples/text_labels_and_annotations/demo_text_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def draw(self, renderer=None):
text_patch = PathClippedImagePatch(text_path, arr, ec="none",
transform=IdentityTransform())

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

# make offset box
offsetbox = AuxTransformBox(IdentityTransform())
Expand Down
34 changes: 26 additions & 8 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,33 +627,51 @@ class Shadow(Patch):
def __str__(self):
return "Shadow(%s)" % (str(self.patch))

@cbook._delete_parameter("3.3", "props")
@docstring.dedent_interpd
def __init__(self, patch, ox, oy, props=None, **kwargs):
"""
Create a shadow of the given *patch* offset by *ox*, *oy*.
*props*, if not *None*, is a patch property update dictionary.
If *None*, the shadow will have have the same color as the face,
Create a shadow of the given *patch*.

By default, the shadow will have the same face color as the *patch*,
but darkened.

Valid keyword arguments are:
Parameters
----------
patch : `.Patch`
The patch to create the shadow for.
ox, oy : float
The shift of the shadow in data coordinates, scaled by a factor
of dpi/72.
props : dict
*deprecated (use kwargs instead)* Properties of the shadow patch.
**kwargs
Properties of the shadow patch. Supported keys are:

%(Patch)s
%(Patch)s
"""
Patch.__init__(self)
self.patch = patch
self.props = props
# Note: when removing props, we can directly pass kwargs to _update()
# and remove self._props
self._props = {**(props if props is not None else {}), **kwargs}
self._ox, self._oy = ox, oy
self._shadow_transform = transforms.Affine2D()
self._update()

@cbook.deprecated("3.3")
@property
def props(self):
return self._props

def _update(self):
self.update_from(self.patch)

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

if self.props is not None:
self.update(self.props)
if self._props:
self.update(self._props)
else:
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
self.set_facecolor(color)
Expand Down