@@ -99,8 +99,19 @@ def process_image(self, padded_src, dpi):
99
99
100
100
101
101
class 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
+ """
104
115
self .gauss_filter = GaussianFilter (sigma , alpha = 1 )
105
116
self .light_source = LightSource ()
106
117
self .fraction = fraction
@@ -114,7 +125,8 @@ def process_image(self, padded_src, dpi):
114
125
rgb = padded_src [:, :, :3 ]
115
126
alpha = padded_src [:, :, 3 :]
116
127
rgb2 = self .light_source .shade_rgb (rgb , elevation ,
117
- fraction = self .fraction )
128
+ fraction = self .fraction ,
129
+ blend_mode = "overlay" )
118
130
return np .concatenate ([rgb2 , alpha ], - 1 )
119
131
120
132
@@ -257,7 +269,7 @@ def drop_shadow_patches(ax):
257
269
258
270
def light_filter_pie (ax ):
259
271
fracs = [15 , 30 , 45 , 10 ]
260
- explode = (0 , 0.05 , 0 , 0 )
272
+ explode = (0.1 , 0.2 , 0.1 , 0.1 )
261
273
pies = ax .pie (fracs , explode = explode )
262
274
263
275
light_filter = LightFilter (9 )
@@ -267,7 +279,7 @@ def light_filter_pie(ax):
267
279
p .set (ec = "none" ,
268
280
lw = 2 )
269
281
270
- gauss = DropShadowFilter (9 , offsets = (3 , 4 ), alpha = 0.7 )
282
+ gauss = DropShadowFilter (9 , offsets = (3 , - 4 ), alpha = 0.7 )
271
283
shadow = FilteredArtistList (pies [0 ], gauss )
272
284
ax .add_artist (shadow )
273
285
shadow .set_zorder (pies [0 ][0 ].get_zorder () - 0.1 )
0 commit comments