@@ -205,6 +205,7 @@ def test_image_alpha():
205
205
plt .subplot (133 )
206
206
plt .imshow (Z , alpha = 0.5 , interpolation = 'nearest' )
207
207
208
+
208
209
def test_cursor_data ():
209
210
from matplotlib .backend_bases import MouseEvent
210
211
@@ -286,7 +287,8 @@ def test_image_cliprect():
286
287
287
288
im = ax .imshow (d , extent = (0 ,5 ,0 ,5 ))
288
289
289
- rect = patches .Rectangle (xy = (1 ,1 ), width = 2 , height = 2 , transform = im .axes .transData )
290
+ rect = patches .Rectangle (
291
+ xy = (1 ,1 ), width = 2 , height = 2 , transform = im .axes .transData )
290
292
im .set_clip_path (rect )
291
293
292
294
@@ -302,23 +304,20 @@ def test_imshow():
302
304
@image_comparison (baseline_images = ['no_interpolation_origin' ],
303
305
remove_text = True )
304
306
def test_no_interpolation_origin ():
305
- fig = plt .figure ()
306
- ax = fig .add_subplot (211 )
307
- ax .imshow (np .arange (100 ).reshape ((2 , 50 )), origin = "lower" ,
308
- interpolation = 'none' )
309
-
310
- ax = fig .add_subplot (212 )
311
- ax .imshow (np .arange (100 ).reshape ((2 , 50 )), interpolation = 'none' )
307
+ fig , axs = plt .subplots (2 )
308
+ axs [0 ].imshow (np .arange (100 ).reshape ((2 , 50 )), origin = "lower" ,
309
+ interpolation = 'none' )
310
+ axs [1 ].imshow (np .arange (100 ).reshape ((2 , 50 )), interpolation = 'none' )
312
311
313
312
314
313
@image_comparison (baseline_images = ['image_shift' ], remove_text = True ,
315
314
extensions = ['pdf' , 'svg' ])
316
315
def test_image_shift ():
317
316
from matplotlib .colors import LogNorm
318
317
319
- imgData = [[1.0 / ( x ) + 1.0 / ( y ) for x in range (1 ,100 )] for y in range (1 ,100 )]
320
- tMin = 734717.945208
321
- tMax = 734717.946366
318
+ imgData = [[1 / x + 1 / y for x in range (1 , 100 )] for y in range (1 , 100 )]
319
+ tMin = 734717.945208
320
+ tMax = 734717.946366
322
321
323
322
fig , ax = plt .subplots ()
324
323
ax .imshow (imgData , norm = LogNorm (), interpolation = 'none' ,
@@ -376,11 +375,13 @@ def test_image_composite_alpha():
376
375
fig , ax = plt .subplots ()
377
376
arr = np .zeros ((11 , 21 , 4 ))
378
377
arr [:, :, 0 ] = 1
379
- arr [:, :, 3 ] = np .concatenate ((np .arange (0 , 1.1 , 0.1 ), np .arange (0 , 1 , 0.1 )[::- 1 ]))
378
+ arr [:, :, 3 ] = np .concatenate (
379
+ (np .arange (0 , 1.1 , 0.1 ), np .arange (0 , 1 , 0.1 )[::- 1 ]))
380
380
arr2 = np .zeros ((21 , 11 , 4 ))
381
381
arr2 [:, :, 0 ] = 1
382
382
arr2 [:, :, 1 ] = 1
383
- arr2 [:, :, 3 ] = np .concatenate ((np .arange (0 , 1.1 , 0.1 ), np .arange (0 , 1 , 0.1 )[::- 1 ]))[:, np .newaxis ]
383
+ arr2 [:, :, 3 ] = np .concatenate (
384
+ (np .arange (0 , 1.1 , 0.1 ), np .arange (0 , 1 , 0.1 )[::- 1 ]))[:, np .newaxis ]
384
385
ax .imshow (arr , extent = [1 , 2 , 5 , 0 ], alpha = 0.3 )
385
386
ax .imshow (arr , extent = [2 , 3 , 5 , 0 ], alpha = 0.6 )
386
387
ax .imshow (arr , extent = [3 , 4 , 5 , 0 ])
@@ -397,21 +398,22 @@ def test_image_composite_alpha():
397
398
remove_text = True , style = 'mpl20' )
398
399
def test_rasterize_dpi ():
399
400
# This test should check rasterized rendering with high output resolution.
400
- # It plots a rasterized line and a normal image with implot. So it will catch
401
- # when images end up in the wrong place in case of non-standard dpi setting.
402
- # Instead of high-res rasterization i use low-res. Therefore the fact that the
403
- # resolution is non-standard is easily checked by image_comparison.
401
+ # It plots a rasterized line and a normal image with implot. So it will
402
+ # catch when images end up in the wrong place in case of non-standard dpi
403
+ # setting. Instead of high-res rasterization I use low-res. Therefore
404
+ # the fact that the resolution is non-standard is easily checked by
405
+ # image_comparison.
404
406
img = np .asarray ([[1 , 2 ], [3 , 4 ]])
405
407
406
- fig , axes = plt .subplots (1 , 3 , figsize = (3 , 1 ))
408
+ fig , axes = plt .subplots (1 , 3 , figsize = (3 , 1 ))
407
409
408
410
axes [0 ].imshow (img )
409
411
410
- axes [1 ].plot ([0 ,1 ],[0 ,1 ], linewidth = 20. , rasterized = True )
411
- axes [1 ].set (xlim = (0 ,1 ), ylim = (- 1 , 2 ))
412
+ axes [1 ].plot ([0 ,1 ], [0 ,1 ], linewidth = 20. , rasterized = True )
413
+ axes [1 ].set (xlim = (0 , 1 ), ylim = (- 1 , 2 ))
412
414
413
- axes [2 ].plot ([0 ,1 ],[0 ,1 ], linewidth = 20. )
414
- axes [2 ].set (xlim = (0 ,1 ), ylim = (- 1 , 2 ))
415
+ axes [2 ].plot ([0 ,1 ], [0 ,1 ], linewidth = 20. )
416
+ axes [2 ].set (xlim = (0 , 1 ), ylim = (- 1 , 2 ))
415
417
416
418
# Low-dpi PDF rasterization errors prevent proper image comparison tests.
417
419
# Hide detailed structures like the axes spines.
@@ -441,8 +443,8 @@ def test_bbox_image_inverted():
441
443
442
444
image = np .identity (10 )
443
445
444
- bbox_im = BboxImage (
445
- TransformedBbox ( Bbox ([[ 0.1 , 0.2 ], [ 0.3 , 0.25 ]]), ax .figure .transFigure ))
446
+ bbox_im = BboxImage (TransformedBbox ( Bbox ([[ 0.1 , 0.2 ], [ 0.3 , 0.25 ]]),
447
+ ax .figure .transFigure ))
446
448
bbox_im .set_data (image )
447
449
bbox_im .set_clip_on (False )
448
450
ax .add_artist (bbox_im )
@@ -459,7 +461,8 @@ def test_get_window_extent_for_AxisImage():
459
461
ax .set_position ([0 , 0 , 1 , 1 ])
460
462
ax .set_xlim (0 , 1 )
461
463
ax .set_ylim (0 , 1 )
462
- im_obj = ax .imshow (im , extent = [0.4 , 0.7 , 0.2 , 0.9 ], interpolation = 'nearest' )
464
+ im_obj = ax .imshow (
465
+ im , extent = [0.4 , 0.7 , 0.2 , 0.9 ], interpolation = 'nearest' )
463
466
464
467
fig .canvas .draw ()
465
468
renderer = fig .canvas .renderer
0 commit comments