@@ -967,6 +967,28 @@ def test_subfigure_double():
967967 axsRight = subfigs [1 ].subplots (2 , 2 )
968968
969969
970+ def test_subfigure_spanning ():
971+ # test that subfigures get laid out properly...
972+ fig = plt .figure (constrained_layout = True )
973+ gs = fig .add_gridspec (3 , 3 )
974+ sub_figs = [
975+ fig .add_subfigure (gs [0 , 0 ]),
976+ fig .add_subfigure (gs [0 :2 , 1 ]),
977+ fig .add_subfigure (gs [2 , 1 :3 ]),
978+ ]
979+
980+ w = 640
981+ h = 480
982+ np .testing .assert_allclose (sub_figs [0 ].bbox .min , [0. , h * 2 / 3 ])
983+ np .testing .assert_allclose (sub_figs [0 ].bbox .max , [w / 3 , h ])
984+
985+ np .testing .assert_allclose (sub_figs [1 ].bbox .min , [w / 3 , h / 3 ])
986+ np .testing .assert_allclose (sub_figs [1 ].bbox .max , [w * 2 / 3 , h ])
987+
988+ np .testing .assert_allclose (sub_figs [2 ].bbox .min , [w / 3 , 0 ])
989+ np .testing .assert_allclose (sub_figs [2 ].bbox .max , [w , h / 3 ])
990+
991+
970992def test_add_subplot_kwargs ():
971993 # fig.add_subplot() always creates new axes, even if axes kwargs differ.
972994 fig = plt .figure ()
0 commit comments