# a child layoutgrid for the gridspec that contains the axes, again # consisting of one row and column. Space is made for the "decorations" on # each side of the axes. In the code, this is accomplished by the entries in # ``do_constrained_layout()`` like:: # # gridspec._layoutgrid[0, 0].edit_margin_min('left', # -bbox.x0 + pos.x0 + w_pad) # # where ``bbox`` is the tight bounding box of the axes, and ``pos`` its # position. Note how the four margins encompass the axes decorations. from matplotlib._layoutgrid import plot_children fig, ax = plt.subplots(constrained_layout=True) example_plot(ax, fontsize=24) plot_children(fig, fig._layoutgrid) ####################################################################### # Simple case: two Axes # --------------------- # When there are multiple axes they have their layouts bound in # simple ways. In this example the left axes has much larger decorations # than the right, but they share a bottom margin, which is made large # enough to accommodate the larger xlabel. Same with the shared top # margin. The left and right margins are not shared, and hence are # allowed to be different. fig, ax = plt.subplots(1, 2, constrained_layout=True) example_plot(ax[0], fontsize=32) example_plot(ax[1], fontsize=8) plot_children(fig, fig._layoutgrid, printit=False)
# a child layoutgrid for the gridspec that contains the axes, again # consisting of one row and column. Space is made for the "decorations" on # each side of the axes. In the code, this is accomplished by the entries in # ``do_constrained_layout()`` like:: # # gridspec._layoutgrid[0, 0].edit_margin_min('left', # -bbox.x0 + pos.x0 + w_pad) # # where ``bbox`` is the tight bounding box of the axes, and ``pos`` its # position. Note how the four margins encompass the axes decorations. from matplotlib._layoutgrid import plot_children fig, ax = plt.subplots(constrained_layout=True) example_plot(ax, fontsize=24) plot_children(fig) ####################################################################### # Simple case: two Axes # --------------------- # When there are multiple axes they have their layouts bound in # simple ways. In this example the left axes has much larger decorations # than the right, but they share a bottom margin, which is made large # enough to accommodate the larger xlabel. Same with the shared top # margin. The left and right margins are not shared, and hence are # allowed to be different. fig, ax = plt.subplots(1, 2, constrained_layout=True) example_plot(ax[0], fontsize=32) example_plot(ax[1], fontsize=8) plot_children(fig, printit=False)