79382144

Date: 2025-01-23 18:17:14
Score: 0.5
Natty:
Report link

You need to use constrained layout:

fig = plt.figure(figsize=(4, 3), layout="constrained")

fig_gridspec = fig.add_gridspec(1, 1)
top_subfig = fig.add_subfigure(fig_gridspec[(0, 0)])
top_subfig.suptitle("I am the top subfig")

top_subfig_gridspec = top_subfig.add_gridspec(1, 1, top=.7)
nested_subfig = top_subfig.add_subfigure(top_subfig_gridspec[(0, 0)])
nested_subfig.suptitle("I am the nested subfig")

ax1 = fig.add_subplot(fig_gridspec[0, 0])
ax2 = fig.add_subplot(top_subfig_gridspec[0, 0])

plt.show()

plot

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: rehaqds