@@ -134,7 +134,7 @@ def test_constrained_layout7():
134134 for gs in gsl :
135135 fig .add_subplot (gs )
136136 # need to trigger a draw to get warning
137- fig .draw ( fig . canvas . get_renderer () )
137+ fig .draw_no_output ( )
138138
139139
140140@image_comparison (['constrained_layout8.png' ])
@@ -327,7 +327,7 @@ def test_constrained_layout18():
327327 ax2 = ax .twinx ()
328328 example_plot (ax )
329329 example_plot (ax2 , fontsize = 24 )
330- fig .canvas . draw ()
330+ fig .draw_no_output ()
331331 assert all (ax .get_position ().extents == ax2 .get_position ().extents )
332332
333333
@@ -339,7 +339,7 @@ def test_constrained_layout19():
339339 example_plot (ax2 , fontsize = 24 )
340340 ax2 .set_title ('' )
341341 ax .set_title ('' )
342- fig .canvas . draw ()
342+ fig .draw_no_output ()
343343 assert all (ax .get_position ().extents == ax2 .get_position ().extents )
344344
345345
@@ -359,11 +359,11 @@ def test_constrained_layout21():
359359 fig , ax = plt .subplots (constrained_layout = True )
360360
361361 fig .suptitle ("Suptitle0" )
362- fig .canvas . draw ()
362+ fig .draw_no_output ()
363363 extents0 = np .copy (ax .get_position ().extents )
364364
365365 fig .suptitle ("Suptitle1" )
366- fig .canvas . draw ()
366+ fig .draw_no_output ()
367367 extents1 = np .copy (ax .get_position ().extents )
368368
369369 np .testing .assert_allclose (extents0 , extents1 )
@@ -373,11 +373,11 @@ def test_constrained_layout22():
373373 """#11035: suptitle should not be include in CL if manually positioned"""
374374 fig , ax = plt .subplots (constrained_layout = True )
375375
376- fig .canvas . draw ()
376+ fig .draw_no_output ()
377377 extents0 = np .copy (ax .get_position ().extents )
378378
379379 fig .suptitle ("Suptitle" , y = 0.5 )
380- fig .canvas . draw ()
380+ fig .draw_no_output ()
381381 extents1 = np .copy (ax .get_position ().extents )
382382
383383 np .testing .assert_allclose (extents0 , extents1 )
@@ -425,7 +425,7 @@ def test_hidden_axes():
425425 # (as does a gridspec slot that is empty)
426426 fig , axs = plt .subplots (2 , 2 , constrained_layout = True )
427427 axs [0 , 1 ].set_visible (False )
428- fig .canvas . draw ()
428+ fig .draw_no_output ()
429429 extents1 = np .copy (axs [0 , 0 ].get_position ().extents )
430430
431431 np .testing .assert_allclose (
@@ -451,7 +451,7 @@ def test_colorbar_align():
451451 fig .set_constrained_layout_pads (w_pad = 4 / 72 , h_pad = 4 / 72 , hspace = 0.1 ,
452452 wspace = 0.1 )
453453
454- fig .canvas . draw ()
454+ fig .draw_no_output ()
455455 if location in ['left' , 'right' ]:
456456 np .testing .assert_allclose (cbs [0 ].ax .get_position ().x0 ,
457457 cbs [2 ].ax .get_position ().x0 )
@@ -493,15 +493,15 @@ def test_colorbars_no_overlapH():
493493def test_manually_set_position ():
494494 fig , axs = plt .subplots (1 , 2 , constrained_layout = True )
495495 axs [0 ].set_position ([0.2 , 0.2 , 0.3 , 0.3 ])
496- fig .canvas . draw ()
496+ fig .draw_no_output ()
497497 pp = axs [0 ].get_position ()
498498 np .testing .assert_allclose (pp , [[0.2 , 0.2 ], [0.5 , 0.5 ]])
499499
500500 fig , axs = plt .subplots (1 , 2 , constrained_layout = True )
501501 axs [0 ].set_position ([0.2 , 0.2 , 0.3 , 0.3 ])
502502 pc = axs [0 ].pcolormesh (np .random .rand (20 , 20 ))
503503 fig .colorbar (pc , ax = axs [0 ])
504- fig .canvas . draw ()
504+ fig .draw_no_output ()
505505 pp = axs [0 ].get_position ()
506506 np .testing .assert_allclose (pp , [[0.2 , 0.2 ], [0.44 , 0.5 ]])
507507
@@ -546,7 +546,7 @@ def test_align_labels():
546546
547547 fig .align_ylabels (axs = (ax3 , ax1 , ax2 ))
548548
549- fig .canvas . draw ()
549+ fig .draw_no_output ()
550550 after_align = [ax1 .yaxis .label .get_window_extent (),
551551 ax2 .yaxis .label .get_window_extent (),
552552 ax3 .yaxis .label .get_window_extent ()]
0 commit comments