FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #24261 on branch v3.6.x (Fix pie chart in demo_agg_filter.py) by meeseeksmachine · Pull Request #24267 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
22 changes: 17 additions & 5 deletions examples/misc/demo_agg_filter.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,19 @@ def process_image(self, padded_src, dpi):


class LightFilter(BaseFilter):

def __init__(self, sigma, fraction=0.5):
"""Apply LightSource filter"""

def __init__(self, sigma, fraction=1):
"""
Parameters
----------
sigma : float
sigma for gaussian filter
fraction: number, default: 1
Increases or decreases the contrast of the hillshade.
See `matplotlib.colors.LightSource`

"""
self.gauss_filter = GaussianFilter(sigma, alpha=1)
self.light_source = LightSource()
self.fraction = fraction
Expand All @@ -114,7 +125,8 @@ def process_image(self, padded_src, dpi):
rgb = padded_src[:, :, :3]
alpha = padded_src[:, :, 3:]
rgb2 = self.light_source.shade_rgb(rgb, elevation,
fraction=self.fraction)
fraction=self.fraction,
blend_mode="overlay")
return np.concatenate([rgb2, alpha], -1)


Expand Down Expand Up @@ -257,7 +269,7 @@ def drop_shadow_patches(ax):

def light_filter_pie(ax):
fracs = [15, 30, 45, 10]
explode = (0, 0.05, 0, 0)
explode = (0.1, 0.2, 0.1, 0.1)
pies = ax.pie(fracs, explode=explode)

light_filter = LightFilter(9)
Expand All @@ -267,7 +279,7 @@ def light_filter_pie(ax):
p.set(ec="none",
lw=2)

gauss = DropShadowFilter(9, offsets=(3, 4), alpha=0.7)
gauss = DropShadowFilter(9, offsets=(3, -4), alpha=0.7)
shadow = FilteredArtistList(pies[0], gauss)
ax.add_artist(shadow)
shadow.set_zorder(pies[0][0].get_zorder() - 0.1)
Expand Down

Back | FazBrowse Home | New Git URL