@@ -348,3 +348,44 @@ def test_constrained_layout20():
348
348
ax = fig .add_axes ([0 , 0 , 1 , 1 ])
349
349
mesh = ax .pcolormesh (gx , gx , img )
350
350
fig .colorbar (mesh )
351
+
352
+ def test_constrained_layout21 ():
353
+ '#11035: repeated calls to suptitle should not alter the layout'
354
+ fig , ax = plt .subplots (constrained_layout = True )
355
+
356
+ fig .suptitle (f"Suptitle #0" )
357
+ fig .canvas .draw ()
358
+ extents0 = np .copy (ax .get_position ().extents )
359
+
360
+ fig .suptitle (f"Suptitle #1" )
361
+ fig .canvas .draw ()
362
+ extents1 = np .copy (ax .get_position ().extents )
363
+
364
+ np .testing .assert_allclose (extents0 , extents1 )
365
+
366
+
367
+ def test_constrained_layout22 ():
368
+ '#11035: suptitle should not be include in CL if manually positioned'
369
+ fig , ax = plt .subplots (constrained_layout = True )
370
+
371
+ fig .canvas .draw ()
372
+ fig .canvas .draw ()
373
+ extents0 = np .copy (ax .get_position ().extents )
374
+
375
+ fig .suptitle (f"Suptitle" , y = 0.5 )
376
+ fig .canvas .draw ()
377
+ fig .canvas .draw ()
378
+ extents1 = np .copy (ax .get_position ().extents )
379
+
380
+ np .testing .assert_allclose (extents0 , extents1 )
381
+
382
+
383
+ def test_constrained_layout23 ():
384
+ '''
385
+ Comment in #11035: suptitle used to cause an exception when
386
+ reusing a figure w/ CL with ``clear=True``.
387
+ '''
388
+
389
+ for i in range (2 ):
390
+ fig , ax = plt .subplots (num = "123" , constrained_layout = True , clear = True )
391
+ fig .suptitle (f"Suptitle { i } " .format (i ))
0 commit comments