@@ -613,12 +613,12 @@ def __str__(self):
613613 return f"Shadow({ self .patch } )"
614614
615615 @_docstring .dedent_interpd
616- def __init__ (self , patch , ox , oy , ** kwargs ):
616+ def __init__ (self , patch , ox , oy , * , shade = 0.7 , * *kwargs ):
617617 """
618618 Create a shadow of the given *patch*.
619619
620620 By default, the shadow will have the same face color as the *patch*,
621- but darkened.
621+ but darkened. The darkness can be controlled by *shade*.
622622
623623 Parameters
624624 ----------
@@ -627,6 +627,12 @@ def __init__(self, patch, ox, oy, **kwargs):
627627 ox, oy : float
628628 The shift of the shadow in data coordinates, scaled by a factor
629629 of dpi/72.
630+ shade : float, default: 0.7
631+ How the darkness of the shadow relates to the original color. If 1, the
632+ shadow is black, if 0, the shadow has the same color as the *patch*.
633+
634+ .. versionadded:: 3.8
635+
630636 **kwargs
631637 Properties of the shadow patch. Supported keys are:
632638
@@ -638,7 +644,9 @@ def __init__(self, patch, ox, oy, **kwargs):
638644 self ._shadow_transform = transforms .Affine2D ()
639645
640646 self .update_from (self .patch )
641- color = .3 * np .asarray (colors .to_rgb (self .patch .get_facecolor ()))
647+ if not 0 <= shade <= 1 :
648+ raise ValueError ("shade must be between 0 and 1." )
649+ color = (1 - shade ) * np .asarray (colors .to_rgb (self .patch .get_facecolor ()))
642650 self .update ({'facecolor' : color , 'edgecolor' : color , 'alpha' : 0.5 ,
643651 # Place shadow patch directly behind the inherited patch.
644652 'zorder' : np .nextafter (self .patch .zorder , - np .inf ),
0 commit comments