99import numpy as np
1010import matplotlib .cm as cm
1111import matplotlib .mlab as mlab
12+ import matplotlib .transforms as mtransforms
13+ from matplotlib .colors import LightSource
14+ from matplotlib .artist import Artist
1215
1316
1417def smooth1d (x , window_len ):
@@ -34,7 +37,7 @@ def smooth2d(A, sigma=3):
3437class BaseFilter (object ):
3538 def prepare_image (self , src_image , dpi , pad ):
3639 ny , nx , depth = src_image .shape
37- #tgt_image = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d")
40+ # tgt_image = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d")
3841 padded_src = np .zeros ([pad * 2 + ny , pad * 2 + nx , depth ], dtype = "d" )
3942 padded_src [pad :- pad , pad :- pad , :] = src_image [:, :, :]
4043
@@ -82,7 +85,7 @@ def get_pad(self, dpi):
8285 return int (self .sigma * 3 / 72. * dpi )
8386
8487 def process_image (self , padded_src , dpi ):
85- #offsetx, offsety = int(self.offsets[0]), int(self.offsets[1])
88+ # offsetx, offsety = int(self.offsets[0]), int(self.offsets[1])
8689 tgt_image = np .zeros_like (padded_src )
8790 aa = smooth2d (padded_src [:, :, - 1 ]* self .alpha ,
8891 self .sigma / 72. * dpi )
@@ -106,9 +109,6 @@ def process_image(self, padded_src, dpi):
106109 return t2
107110
108111
109- from matplotlib .colors import LightSource
110-
111-
112112class LightFilter (BaseFilter ):
113113 "simple gauss filter"
114114
@@ -160,9 +160,6 @@ def __call__(self, im, dpi):
160160 return new_im , offsetx , offsety
161161
162162
163- from matplotlib .artist import Artist
164-
165-
166163class FilteredArtistList (Artist ):
167164 """
168165 A simple container to draw filtered artist.
@@ -182,9 +179,6 @@ def draw(self, renderer):
182179 renderer .stop_rasterizing ()
183180
184181
185- import matplotlib .transforms as mtransforms
186-
187-
188182def filtered_text (ax ):
189183 # mostly copied from contour_demo.py
190184
@@ -281,9 +275,10 @@ def drop_shadow_patches(ax):
281275 rects1 = ax .bar (ind , menMeans , width , color = 'r' , ec = "w" , lw = 2 )
282276
283277 womenMeans = (25 , 32 , 34 , 20 , 25 )
284- rects2 = ax .bar (ind + width + 0.1 , womenMeans , width , color = 'y' , ec = "w" , lw = 2 )
278+ rects2 = ax .bar (ind + width + 0.1 , womenMeans , width ,
279+ color = 'y' , ec = "w" , lw = 2 )
285280
286- #gauss = GaussianFilter(1.5, offsets=(1,1), )
281+ # gauss = GaussianFilter(1.5, offsets=(1,1), )
287282 gauss = DropShadowFilter (5 , offsets = (1 , 1 ), )
288283 shadow = FilteredArtistList (rects1 + rects2 , gauss )
289284 ax .add_artist (shadow )
0 commit comments