Skip to content

Commit 55f22d9

Browse files
committed
FIX: revert change to signature so we can test if kwargs used
1 parent 7e335c3 commit 55f22d9

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lib/matplotlib/figure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def get_window_extent(self, *args, **kwargs):
677677
"""
678678
return self.bbox
679679

680-
def suptitle(self, t, *, x=.5, y=.98, **kwargs):
680+
def suptitle(self, t, **kwargs):
681681
"""
682682
Add a centered title to the figure.
683683

lib/matplotlib/tests/test_constrainedlayout.py

+41
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,44 @@ def test_constrained_layout20():
348348
ax = fig.add_axes([0, 0, 1, 1])
349349
mesh = ax.pcolormesh(gx, gx, img)
350350
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

Comments
 (0)