Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02d7f38

Browse files
authored
Merge pull request #12740 from pharshalp/constrained_layout_doc_fix
DOC: constrained layout guide (fix: Spacing with colorbars)
2 parents ac0525e + 28b5cb9 commit 02d7f38

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
@@ -300,15 +300,17 @@ def example_plot(ax, fontsize=12, nodec=False):
300300
# Spacing with colorbars
301301
# -----------------------
302302
#
303-
# Colorbars still respect the ``w_pad`` and ``h_pad`` values. However they will
304-
# be ``wspace`` and ``hsapce`` apart from other subplots. Note the use of a
305-
# ``pad`` kwarg here in the ``colorbar`` call. It defaults to 0.02 of the size
303+
# Colorbars will be placed ``wspace`` and ``hsapce`` apart from other
304+
# subplots. The padding between the colorbar and the axis it is
305+
# attached to will never be less than ``w_pad`` (for a vertical colorbar)
306+
# or ``h_pad`` (for a horizontal colorbar). Note the use of the ``pad`` kwarg
307+
# here in the ``colorbar`` call. It defaults to 0.02 of the size
306308
# of the axis it is attached to.
307309

308310
fig, axs = plt.subplots(2, 2, constrained_layout=True)
309311
for ax in axs.flatten():
310312
pc = ax.pcolormesh(arr, **pc_kwargs)
311-
fig.colorbar(im, ax=ax, shrink=0.6, pad=0)
313+
fig.colorbar(pc, ax=ax, shrink=0.6, pad=0)
312314
ax.set_xticklabels('')
313315
ax.set_yticklabels('')
314316
fig.set_constrained_layout_pads(w_pad=2./72., h_pad=2./72.,

0 commit comments

Comments
 (0)