Skip to content

Commit ab3478c

Browse files
committed
Fix default artist properties for Shadow.
Starting with #16098, extra keyword arguments are now processed, but that means that default colours and alpha are not set. Instead, those properties should only be overridden if specified.
1 parent 31e26cc commit ab3478c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/matplotlib/patches.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,14 @@ def __init__(self, patch, ox, oy, props=None, **kwargs):
645645
self.patch = patch
646646
# Note: when removing props, we can directly pass kwargs to _update()
647647
# and remove self._props
648-
self._props = {**(props if props is not None else {}), **kwargs}
648+
if props is None:
649+
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
650+
props = {
651+
'facecolor': color,
652+
'edgecolor': color,
653+
'alpha': 0.5,
654+
}
655+
self._props = {**props, **kwargs}
649656
self._ox, self._oy = ox, oy
650657
self._shadow_transform = transforms.Affine2D()
651658
self._update()
@@ -658,13 +665,7 @@ def _update(self):
658665
# Place the shadow patch directly behind the inherited patch.
659666
self.set_zorder(np.nextafter(self.patch.zorder, -np.inf))
660667

661-
if self._props:
662-
self.update(self._props)
663-
else:
664-
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
665-
self.set_facecolor(color)
666-
self.set_edgecolor(color)
667-
self.set_alpha(0.5)
668+
self.update(self._props)
668669

669670
def _update_transform(self, renderer):
670671
ox = renderer.points_to_pixels(self._ox)

0 commit comments

Comments
 (0)