Skip to content

Commit 6f8463a

Browse files
meeseeksmachinetimhoffm
authored andcommitted
Backport PR #12740: DOC: constrained layout guide (fix: Spacing with colorbars) (#12741)
1 parent 6e176fd commit 6f8463a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tutorials/intermediate/constrainedlayout_guide.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,17 @@ def example_plot(ax, fontsize=12, nodec=False):
305305
# Spacing with colorbars
306306
# -----------------------
307307
#
308-
# Colorbars still respect the ``w_pad`` and ``h_pad`` values. However they will
309-
# be ``wspace`` and ``hsapce`` apart from other subplots. Note the use of a
310-
# ``pad`` kwarg here in the ``colorbar`` call. It defaults to 0.02 of the size
308+
# Colorbars will be placed ``wspace`` and ``hsapce`` apart from other
309+
# subplots. The padding between the colorbar and the axis it is
310+
# attached to will never be less than ``w_pad`` (for a vertical colorbar)
311+
# or ``h_pad`` (for a horizontal colorbar). Note the use of the ``pad`` kwarg
312+
# here in the ``colorbar`` call. It defaults to 0.02 of the size
311313
# of the axis it is attached to.
312314

313315
fig, axs = plt.subplots(2, 2, constrained_layout=True)
314316
for ax in axs.flatten():
315317
pc = ax.pcolormesh(arr, **pc_kwargs)
316-
fig.colorbar(im, ax=ax, shrink=0.6, pad=0)
318+
fig.colorbar(pc, ax=ax, shrink=0.6, pad=0)
317319
ax.set_xticklabels('')
318320
ax.set_yticklabels('')
319321
fig.set_constrained_layout_pads(w_pad=2./72., h_pad=2./72.,

0 commit comments

Comments
 (0)