@@ -279,13 +279,16 @@ def test_colorbar_single_scatter():
279279 plt .colorbar (cs )
280280
281281
282- @pytest .mark .parametrize ('use_gridspec' , [False , True ],
283- ids = ['no gridspec' , 'with gridspec' ])
284- def test_remove_from_figure (use_gridspec ):
285- """
286- Test `remove` with the specified ``use_gridspec`` setting
287- """
288- fig , ax = plt .subplots ()
282+ @pytest .mark .parametrize ('use_gridspec' , [True , False ])
283+ @pytest .mark .parametrize ('nested_gridspecs' , [True , False ])
284+ def test_remove_from_figure (nested_gridspecs , use_gridspec ):
285+ """Test `remove` with the specified ``use_gridspec`` setting."""
286+ fig = plt .figure ()
287+ if nested_gridspecs :
288+ gs = fig .add_gridspec (2 , 2 )[1 , 1 ].subgridspec (2 , 2 )
289+ ax = fig .add_subplot (gs [1 , 1 ])
290+ else :
291+ ax = fig .add_subplot ()
289292 sc = ax .scatter ([1 , 2 ], [3 , 4 ])
290293 sc .set_array (np .array ([5 , 6 ]))
291294 pre_position = ax .get_position ()
@@ -298,9 +301,7 @@ def test_remove_from_figure(use_gridspec):
298301
299302
300303def test_remove_from_figure_cl ():
301- """
302- Test `remove` with constrained_layout
303- """
304+ """Test `remove` with constrained_layout."""
304305 fig , ax = plt .subplots (constrained_layout = True )
305306 sc = ax .scatter ([1 , 2 ], [3 , 4 ])
306307 sc .set_array (np .array ([5 , 6 ]))
0 commit comments