@@ -86,6 +86,7 @@ def do_figimage(suppressComposite):
8686 fig .figimage (img [:,::- 1 ], xo = 100 , yo = 0 , origin = 'lower' )
8787 fig .figimage (img [::- 1 ,::- 1 ], xo = 100 , yo = 100 , origin = 'lower' )
8888
89+
8990@image_comparison (baseline_images = ['figimage-0' ],
9091 extensions = ['png' ,'pdf' ])
9192def test_figimage0 ():
@@ -849,3 +850,22 @@ def test_full_invalid():
849850 ax .imshow (x )
850851
851852 f .canvas .draw ()
853+
854+
855+ @pytest .mark .parametrize ("fmt,counted" ,
856+ [("ps" , b" colorimage" ), ("svg" , b"<image" )])
857+ @pytest .mark .parametrize ("composite_image,count" , [(True , 1 ), (False , 2 )])
858+ def test_composite (fmt , counted , composite_image , count ):
859+ # Test that figures can be saved with and without combining multiple images
860+ # (on a single set of axes) into a single composite image.
861+ X , Y = np .meshgrid (np .arange (- 5 , 5 , 1 ), np .arange (- 5 , 5 , 1 ))
862+ Z = np .sin (Y ** 2 )
863+ fig = plt .figure ()
864+ ax = fig .add_subplot (1 , 1 , 1 )
865+ ax .set_xlim (0 , 3 )
866+ ax .imshow (Z , extent = [0 , 1 , 0 , 1 ])
867+ ax .imshow (Z [::- 1 ], extent = [2 , 3 , 0 , 1 ])
868+ plt .rcParams ['image.composite_image' ] = composite_image
869+ buf = io .BytesIO ()
870+ fig .savefig (buf , format = fmt )
871+ assert buf .getvalue ().count (counted ) == count
0 commit comments