Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a0e4c04

Browse filesBrowse files
committed
FIX: make suptitle be in CL only if placed automatically
1 parent c57d1a6 commit a0e4c04
Copy full SHA for a0e4c04

File tree

Expand file treeCollapse file tree

2 files changed

+18
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-11
lines changed

‎lib/matplotlib/_constrained_layout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_constrained_layout.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def do_constrained_layout(fig, renderer, h_pad, w_pad,
244244
ax._poslayoutbox.constrain_left_margin(0, strength='weak')
245245

246246
# do layout for suptitle.
247-
if fig._suptitle is not None:
247+
if fig._suptitle is not None and fig._suptitle._layoutbox is not None:
248248
sup = fig._suptitle
249249
bbox = invTransFig(sup.get_window_extent(renderer=renderer))
250250
height = bbox.y1 - bbox.y0

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+17-10Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ def suptitle(self, t, **kwargs):
731731
732732
>>> fig.suptitle('This is the figure title', fontsize=12)
733733
"""
734+
manual_position = ('x' in kwargs or 'y' in kwargs)
735+
734736
x = kwargs.pop('x', 0.5)
735737
y = kwargs.pop('y', 0.98)
736738

@@ -754,17 +756,22 @@ def suptitle(self, t, **kwargs):
754756
else:
755757
self._suptitle = sup
756758
if self._layoutbox is not None:
757-
figlb = self._layoutbox
758-
self._suptitle._layoutbox = layoutbox.LayoutBox(
759-
parent=figlb,
759+
if not manual_position:
760+
figlb = self._layoutbox
761+
self._suptitle._layoutbox = \
762+
layoutbox.LayoutBox(parent=figlb,
760763
name=figlb.name+'.suptitle')
761-
for child in figlb.children:
762-
if not (child == self._suptitle._layoutbox):
763-
w_pad, h_pad, wspace, hspace = \
764-
self.get_constrained_layout_pads(
765-
relative=True)
766-
layoutbox.vstack([self._suptitle._layoutbox, child],
767-
padding=h_pad*2., strength='required')
764+
for child in figlb.children:
765+
if not (child == self._suptitle._layoutbox):
766+
w_pad, h_pad, wspace, hspace = \
767+
self.get_constrained_layout_pads(
768+
relative=True)
769+
layoutbox.vstack([self._suptitle._layoutbox,
770+
child],
771+
padding=h_pad*2.,
772+
strength='required')
773+
else:
774+
self._suptitle._layoutbox = None
768775
self.stale = True
769776
return self._suptitle
770777

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.