@@ -58,7 +58,7 @@ def _get_color_filter(name):
58
58
59
59
def filter(input: np.ndarray[M, N, D])-> np.ndarray[M, N, D]
60
60
61
- where (M, N) are the image dimentions , and D is the color depth (3 for
61
+ where (M, N) are the image dimensions , and D is the color depth (3 for
62
62
RGB, 4 for RGBA). Alpha is passed through unchanged and otherwise
63
63
ignored.
64
64
"""
@@ -259,3 +259,48 @@ def _setup_wx(tb):
259
259
id = item .Id ,
260
260
)
261
261
tb .SetDropdownMenu (tool .Id , menu )
262
+
263
+
264
+ if __name__ == '__main__' :
265
+ import matplotlib .pyplot as plt
266
+ from matplotlib import cbook
267
+
268
+ plt .rcParams ['figure.hooks' ].append ('mplcvd:setup' )
269
+
270
+ fig , axd = plt .subplot_mosaic (
271
+ [
272
+ ['viridis' , 'turbo' ],
273
+ ['photo' , 'lines' ]
274
+ ]
275
+ )
276
+
277
+ delta = 0.025
278
+ x = y = np .arange (- 3.0 , 3.0 , delta )
279
+ X , Y = np .meshgrid (x , y )
280
+ Z1 = np .exp (- X ** 2 - Y ** 2 )
281
+ Z2 = np .exp (- (X - 1 )** 2 - (Y - 1 )** 2 )
282
+ Z = (Z1 - Z2 ) * 2
283
+
284
+ imv = axd ['viridis' ].imshow (
285
+ Z , interpolation = 'bilinear' ,
286
+ origin = 'lower' , extent = [- 3 , 3 , - 3 , 3 ],
287
+ vmax = abs (Z ).max (), vmin = - abs (Z ).max ()
288
+ )
289
+ fig .colorbar (imv )
290
+ imt = axd ['turbo' ].imshow (
291
+ Z , interpolation = 'bilinear' , cmap = 'turbo' ,
292
+ origin = 'lower' , extent = [- 3 , 3 , - 3 , 3 ],
293
+ vmax = abs (Z ).max (), vmin = - abs (Z ).max ()
294
+ )
295
+ fig .colorbar (imt )
296
+
297
+ # A sample image
298
+ with cbook .get_sample_data ('grace_hopper.jpg' ) as image_file :
299
+ photo = plt .imread (image_file )
300
+ axd ['photo' ].imshow (photo )
301
+
302
+ th = np .linspace (0 , 2 * np .pi , 1024 )
303
+ for j in [1 , 2 , 4 , 6 ]:
304
+ axd ['lines' ].plot (th , np .sin (th * j ), label = f'$\\ omega={ j } $' )
305
+ axd ['lines' ].legend (ncol = 2 , loc = 'upper right' )
306
+ plt .show ()
0 commit comments