@@ -615,12 +615,12 @@ def __str__(self):
615
615
return f"Shadow({ self .patch } )"
616
616
617
617
@_docstring .dedent_interpd
618
- def __init__ (self , patch , ox , oy , ** kwargs ):
618
+ def __init__ (self , patch , ox , oy , * , shade = 0.3 , * *kwargs ):
619
619
"""
620
620
Create a shadow of the given *patch*.
621
621
622
622
By default, the shadow will have the same face color as the *patch*,
623
- but darkened.
623
+ but darkened. The darkness can be controlled by *shade*.
624
624
625
625
Parameters
626
626
----------
@@ -629,6 +629,9 @@ def __init__(self, patch, ox, oy, **kwargs):
629
629
ox, oy : float
630
630
The shift of the shadow in data coordinates, scaled by a factor
631
631
of dpi/72.
632
+ shade : float, default: 0.3
633
+ How the darkness of the shadow relates to the original color. If 0, the
634
+ shadow is black, if 1, the shadow has the same color as the *patch*.
632
635
**kwargs
633
636
Properties of the shadow patch. Supported keys are:
634
637
@@ -640,7 +643,9 @@ def __init__(self, patch, ox, oy, **kwargs):
640
643
self ._shadow_transform = transforms .Affine2D ()
641
644
642
645
self .update_from (self .patch )
643
- color = .3 * np .asarray (colors .to_rgb (self .patch .get_facecolor ()))
646
+ if not 0 <= shade <= 1 :
647
+ raise ValueError ("shade must be between 0 and 1." )
648
+ color = shade * np .asarray (colors .to_rgb (self .patch .get_facecolor ()))
644
649
self .update ({'facecolor' : color , 'edgecolor' : color , 'alpha' : 0.5 ,
645
650
# Place shadow patch directly behind the inherited patch.
646
651
'zorder' : np .nextafter (self .patch .zorder , - np .inf ),
0 commit comments