示例#1
0
# outer Gridspec layoutboxes coincide.  The Subplotspec and Axes
# boxes also coincide because the Axes has no colorbar.  Note
# the difference between the red ``pos`` box and the green ``ax`` box
# is set by the size of the decorations around the Axes.
#
# In the code, this is accomplished by the entries in
# ``do_constrained_layout()`` like::
#
#     ax._poslayoutbox.edit_left_margin_min(-bbox.x0 + pos.x0 + w_padt)
#

from matplotlib._layoutbox import plot_children

fig, ax = plt.subplots(constrained_layout=True)
example_plot(ax, fontsize=24)
plot_children(fig, fig._layoutbox, printit=False)

#######################################################################
# Simple case: two Axes
# ---------------------
# For this case, the Axes layoutboxes and the Subplotspec boxes still
# co-incide.  However, because the decorations in the right-hand plot are so
# much smaller than the left-hand, so the right-hand layoutboxes are smaller.
#
# The Subplotspec boxes are laid out in the code in the subroutine
# ``arange_subplotspecs()``, which simply checks the subplotspecs in the code
# against one another and stacks them appropriately.
#
# The two ``pos`` axes are lined up.  Because they have the same
# minimum row, they are lined up at the top. Because
# they have the same maximum row they are lined up at the bottom.  In the
# outer Gridspec layoutboxes coincide.  The Subplotspec and Axes
# boxes also coincide because the Axes has no colorbar.  Note
# the difference between the red ``pos`` box and the green ``ax`` box
# is set by the size of the decorations around the Axes.
#
# In the code, this is accomplished by the entries in
# ``do_constrained_layout()`` like::
#
#     ax._poslayoutbox.edit_left_margin_min(-bbox.x0 + pos.x0 + w_padt)
#

from matplotlib._layoutbox import plot_children

fig, ax = plt.subplots(constrained_layout=True)
example_plot(ax, fontsize=24)
plot_children(fig, fig._layoutbox, printit=False)

#######################################################################
# Simple case: two Axes
# ---------------------
# For this case, the Axes layoutboxes and the Subplotspec boxes still
# co-incide.  However, because the decorations in the right-hand plot are so
# much smaller than the left-hand, so the right-hand layoutboxes are smaller.
#
# The Subplotspec boxes are laid out in the code in the subroutine
# ``arange_subplotspecs()``, which simply checks the subplotspecs in the code
# against one another and stacks them appropriately.
#
# The two ``pos`` axes are lined up.  Because they have the same
# minimum row, they are lined up at the top. Because
# they have the same maximum row they are lined up at the bottom.  In the