@@ -99,8 +99,19 @@ def process_image(self, padded_src, dpi):
9999
100100
101101class LightFilter (BaseFilter ):
102-
103- def __init__ (self , sigma , fraction = 0.5 ):
102+ """Apply LightSource filter"""
103+
104+ def __init__ (self , sigma , fraction = 1 ):
105+ """
106+ Parameters
107+ ----------
108+ sigma : float
109+ sigma for gaussian filter
110+ fraction: number, default: 1
111+ Increases or decreases the contrast of the hillshade.
112+ See `matplotlib.colors.LightSource`
113+
114+ """
104115 self .gauss_filter = GaussianFilter (sigma , alpha = 1 )
105116 self .light_source = LightSource ()
106117 self .fraction = fraction
@@ -114,7 +125,8 @@ def process_image(self, padded_src, dpi):
114125 rgb = padded_src [:, :, :3 ]
115126 alpha = padded_src [:, :, 3 :]
116127 rgb2 = self .light_source .shade_rgb (rgb , elevation ,
117- fraction = self .fraction )
128+ fraction = self .fraction ,
129+ blend_mode = "overlay" )
118130 return np .concatenate ([rgb2 , alpha ], - 1 )
119131
120132
@@ -257,7 +269,7 @@ def drop_shadow_patches(ax):
257269
258270def light_filter_pie (ax ):
259271 fracs = [15 , 30 , 45 , 10 ]
260- explode = (0 , 0.05 , 0 , 0 )
272+ explode = (0.1 , 0.2 , 0.1 , 0.1 )
261273 pies = ax .pie (fracs , explode = explode )
262274
263275 light_filter = LightFilter (9 )
@@ -267,7 +279,7 @@ def light_filter_pie(ax):
267279 p .set (ec = "none" ,
268280 lw = 2 )
269281
270- gauss = DropShadowFilter (9 , offsets = (3 , 4 ), alpha = 0.7 )
282+ gauss = DropShadowFilter (9 , offsets = (3 , - 4 ), alpha = 0.7 )
271283 shadow = FilteredArtistList (pies [0 ], gauss )
272284 ax .add_artist (shadow )
273285 shadow .set_zorder (pies [0 ][0 ].get_zorder () - 0.1 )
0 commit comments