@@ -613,12 +613,12 @@ def __str__(self):
613
613
return f"Shadow({ self .patch } )"
614
614
615
615
@_docstring .dedent_interpd
616
- def __init__ (self , patch , ox , oy , ** kwargs ):
616
+ def __init__ (self , patch , ox , oy , * , shade = 0.7 , * *kwargs ):
617
617
"""
618
618
Create a shadow of the given *patch*.
619
619
620
620
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*.
622
622
623
623
Parameters
624
624
----------
@@ -627,6 +627,12 @@ def __init__(self, patch, ox, oy, **kwargs):
627
627
ox, oy : float
628
628
The shift of the shadow in data coordinates, scaled by a factor
629
629
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
+
630
636
**kwargs
631
637
Properties of the shadow patch. Supported keys are:
632
638
@@ -638,7 +644,9 @@ def __init__(self, patch, ox, oy, **kwargs):
638
644
self ._shadow_transform = transforms .Affine2D ()
639
645
640
646
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 ()))
642
650
self .update ({'facecolor' : color , 'edgecolor' : color , 'alpha' : 0.5 ,
643
651
# Place shadow patch directly behind the inherited patch.
644
652
'zorder' : np .nextafter (self .patch .zorder , - np .inf ),
0 commit comments