Skip to content

Commit dd6d054

Browse files
authored
Merge pull request #24267 from meeseeksmachine/auto-backport-of-pr-24261-on-v3.6.x
Backport PR #24261 on branch v3.6.x (Fix pie chart in demo_agg_filter.py)
2 parents 539eb5b + f7e47ac commit dd6d054

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

examples/misc/demo_agg_filter.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,19 @@ def process_image(self, padded_src, dpi):
9999

100100

101101
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+
"""
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

258270
def 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

Comments
 (0)