diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 81f8aa4ee4d4..076e719df208 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3076,8 +3076,7 @@ def get_next_color(): if shadow: # Make sure to add a shadow after the call to add_patch so the # figure and transform props will be set. - shad = mpatches.Shadow(w, -0.02, -0.02) - shad.set(zorder=0.9 * w.get_zorder(), label='_nolegend_') + shad = mpatches.Shadow(w, -0.02, -0.02, label='_nolegend_') self.add_patch(shad) if labeldistance is not None: diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 490148ed0794..5811cba39ada 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -645,7 +645,14 @@ def __init__(self, patch, ox, oy, props=None, **kwargs): self.patch = patch # 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} + if props is None: + color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor())) + props = { + 'facecolor': color, + 'edgecolor': color, + 'alpha': 0.5, + } + self._props = {**props, **kwargs} self._ox, self._oy = ox, oy self._shadow_transform = transforms.Affine2D() self._update() @@ -658,13 +665,7 @@ def _update(self): # Place the shadow patch directly behind the inherited patch. self.set_zorder(np.nextafter(self.patch.zorder, -np.inf)) - if self._props: - self.update(self._props) - else: - color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor())) - self.set_facecolor(color) - self.set_edgecolor(color) - self.set_alpha(0.5) + self.update(self._props) def _update_transform(self, renderer): ox = renderer.points_to_pixels(self._ox)