@@ -447,12 +447,48 @@ def test_nonuniformimage_setcmap():
447
447
im = NonUniformImage (ax )
448
448
im .set_cmap ('Blues' )
449
449
450
+
450
451
@cleanup
451
452
def test_nonuniformimage_setnorm ():
452
453
ax = plt .gca ()
453
454
im = NonUniformImage (ax )
454
455
im .set_norm (plt .Normalize ())
455
456
457
+
458
+ @cleanup
459
+ def test_minimized_rasterized ():
460
+ # This ensures that the rasterized content in the colorbars is
461
+ # only as thick as the colorbar, and doesn't extend to other parts
462
+ # of the image. See #5814. While the original bug exists only
463
+ # in Postscript, the best way to detect it is to generate SVG
464
+ # and then parse the output to make sure the two colorbar images
465
+ # are the same size.
466
+ from xml .etree import ElementTree
467
+
468
+ np .random .seed (0 )
469
+ data = np .random .rand (10 , 10 )
470
+
471
+ fig , ax = plt .subplots (1 , 2 )
472
+ p1 = ax [0 ].pcolormesh (data )
473
+ p2 = ax [1 ].pcolormesh (data )
474
+
475
+ plt .colorbar (p1 , ax = ax [0 ])
476
+ plt .colorbar (p2 , ax = ax [1 ])
477
+
478
+ buff = io .BytesIO ()
479
+ plt .savefig (buff , format = 'svg
8000
9; )
480
+
481
+ buff = io .BytesIO (buff .getvalue ())
482
+ tree = ElementTree .parse (buff )
483
+ width = None
484
+ for image in tree .iter ('image' ):
485
+ if width is None :
486
+ width = image ['width' ]
487
+ else :
488
+ if image ['width' ] != width :
489
+ assert False
490
+
491
+
456
492
if __name__ == '__main__' :
457
493
import nose
458
494
nose .runmodule (argv = ['-s' ,'--with-doctest' ], exit = False )
0 commit comments