Skip to content

Commit 96e69ed

Browse files
leejjoonQuLogic
andauthored
Fix pie chart in demo_agg_filter.py (#24261)
* fix demo_agg_filter.py * Update examples/misc/demo_agg_filter.py Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent e148998 commit 96e69ed

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

examples/misc/demo_agg_filter.py

Lines changed: 17 additions & 5 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy