Closed
Description
Bug summary
Location of subfigure shifts lower on y-axis when 'x' kwarg is used for supxlabel for that subfigure.
I've also posted to StackOverflow: https://stackoverflow.com/q/68567315/9249533
Code for reproduction
fig = plt.figure(constrained_layout=True, figsize=(10, 8))
# create top/bottom subfigs
# see https://stackoverflow.com/a/68553015/9249533
(subfig_t, subfig_b) = fig.subfigures(2, 1, hspace=0.05, height_ratios=[1, 3])
# put ax0 in top subfig
ax0 = subfig_t.subplots()
# create left/right subfigs nested in bottom subfig
(subfig_bl, subfig_br) = subfig_b.subfigures(1, 2, wspace=0.1, width_ratios=[3, 1])
# put ax1-ax3 in gridspec of bottom-left subfig
gs = subfig_bl.add_gridspec(nrows=1, ncols=9)
ax1 = subfig_bl.add_subplot(gs[0, :3])
ax2 = subfig_bl.add_subplot(gs[0, 3:6], sharey=ax1)
ax3 = subfig_bl.add_subplot(gs[0, 6:9], sharey=ax1)
ax1.set_title('Nov. 7 to Nov. 13')
ax2.set_title('Nov. 13 to Nov. 27')
ax3.set_title('Nov. 27 to Dec. 31')
ax2.get_yaxis().set_visible(False)
ax3.get_yaxis().set_visible(False)
subfig_bl.supxlabel("My Subfigure Label", x=0.54, size=12, fontweight='bold')
# put ax4 in bottom-right subfig
ax4 = subfig_br.subplots()
ax4.set_title('Some Other Title')
subfig_br.supxlabel('Other Subfigure SubLabel', size=12, fontweight='bold')
Actual outcome
Body of subfigure shifts downward (lower on y-axis) and covers supxlabel
Expected outcome
subfigure position doesn't change. supxlabel shifts to right.
Operating system
Windows 10 Pro
Matplotlib Version
3.4.2
Matplotlib Backend
No response
Python version
3.9.5
Jupyter version
3.0.16
Other libraries
No response
Installation
conda
Conda channel
conda-forge