@@ -134,7 +134,7 @@ def test_constrained_layout7():
134
134
for gs in gsl :
135
135
fig .add_subplot (gs )
136
136
# need to trigger a draw to get warning
137
- fig .draw ( fig . canvas . get_renderer () )
137
+ fig .draw_no_output ( )
138
138
139
139
140
140
@image_comparison (['constrained_layout8.png' ])
@@ -327,7 +327,7 @@ def test_constrained_layout18():
327
327
ax2 = ax .twinx ()
328
328
example_plot (ax )
329
329
example_plot (ax2 , fontsize = 24 )
330
- fig .canvas . draw ()
330
+ fig .draw_no_output ()
331
331
assert all (ax .get_position ().extents == ax2 .get_position ().extents )
332
332
333
333
@@ -339,7 +339,7 @@ def test_constrained_layout19():
339
339
example_plot (ax2 , fontsize = 24 )
340
340
ax2 .set_title ('' )
341
341
ax .set_title ('' )
342
- fig .canvas . draw ()
342
+ fig .draw_no_output ()
343
343
assert all (ax .get_position ().extents == ax2 .get_position ().extents )
344
344
345
345
@@ -359,11 +359,11 @@ def test_constrained_layout21():
359
359
fig , ax = plt .subplots (constrained_layout = True )
360
360
361
361
fig .suptitle ("Suptitle0" )
362
- fig .canvas . draw ()
362
+ fig .draw_no_output ()
363
363
extents0 = np .copy (ax .get_position ().extents )
364
364
365
365
fig .suptitle ("Suptitle1" )
366
- fig .canvas . draw ()
366
+ fig .draw_no_output ()
367
367
extents1 = np .copy (ax .get_position ().extents )
368
368
369
369
np .testing .assert_allclose (extents0 , extents1 )
@@ -373,11 +373,11 @@ def test_constrained_layout22():
373
373
"""#11035: suptitle should not be include in CL if manually positioned"""
374
374
fig , ax = plt .subplots (constrained_layout = True )
375
375
376
- fig .canvas . draw ()
376
+ fig .draw_no_output ()
377
377
extents0 = np .copy (ax .get_position ().extents )
378
378
379
379
fig .suptitle ("Suptitle" , y = 0.5 )
380
- fig .canvas . draw ()
380
+ fig .draw_no_output ()
381
381
extents1 = np .copy (ax .get_position ().extents )
382
382
383
383
np .testing .assert_allclose (extents0 , extents1 )
@@ -425,7 +425,7 @@ def test_hidden_axes():
425
425
# (as does a gridspec slot that is empty)
426
426
fig , axs = plt .subplots (2 , 2 , constrained_layout = True )
427
427
axs [0 , 1 ].set_visible (False )
428
- fig .canvas . draw ()
428
+ fig .draw_no_output ()
429
429
extents1 = np .copy (axs [0 , 0 ].get_position ().extents )
430
430
431
431
np .testing .assert_allclose (
@@ -451,7 +451,7 @@ def test_colorbar_align():
451
451
fig .set_constrained_layout_pads (w_pad = 4 / 72 , h_pad = 4 / 72 , hspace = 0.1 ,
452
452
wspace = 0.1 )
453
453
454
- fig .canvas . draw ()
454
+ fig .draw_no_output ()
455
455
if location in ['left' , 'right' ]:
456
456
np .testing .assert_allclose (cbs [0 ].ax .get_position ().x0 ,
457
457
cbs [2 ].ax .get_position ().x0 )
@@ -493,15 +493,15 @@ def test_colorbars_no_overlapH():
493
493
def test_manually_set_position ():
494
494
fig , axs = plt .subplots (1 , 2 , constrained_layout = True )
495
495
axs [0 ].set_position ([0.2 , 0.2 , 0.3 , 0.3 ])
496
- fig .canvas . draw ()
496
+ fig .draw_no_output ()
497
497
pp = axs [0 ].get_position ()
498
498
np .testing .assert_allclose (pp , [[0.2 , 0.2 ], [0.5 , 0.5 ]])
499
499
500
500
fig , axs = plt .subplots (1 , 2 , constrained_layout = True )
501
501
axs [0 ].set_position ([0.2 , 0.2 , 0.3 , 0.3 ])
502
502
pc = axs [0 ].pcolormesh (np .random .rand (20 , 20 ))
503
503
fig .colorbar (pc , ax = axs [0 ])
504
- fig .canvas . draw ()
504
+ fig .draw_no_output ()
505
505
pp = axs [0 ].get_position ()
506
506
np .testing .assert_allclose (pp , [[0.2 , 0.2 ], [0.44 , 0.5 ]])
507
507
@@ -546,7 +546,7 @@ def test_align_labels():
546
546
547
547
fig .align_ylabels (axs = (ax3 , ax1 , ax2 ))
548
548
549
- fig .canvas . draw ()
549
+ fig .draw_no_output ()
550
550
after_align = [ax1 .yaxis .label .get_window_extent (),
551
551
ax2 .yaxis .label .get_window_extent (),
552
552
ax3 .yaxis .label .get_window_extent ()]
0 commit comments