Skip to content

Commit

Permalink
Merge pull request matplotlib#12740 from pharshalp/constrained_layout…
Browse files Browse the repository at this point in the history
…_doc_fix

DOC: constrained layout guide (fix: Spacing with colorbars)
  • Loading branch information
jklymak authored Nov 4, 2018
2 parents ac0525e + 28b5cb9 commit 02d7f38
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tutorials/intermediate/constrainedlayout_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,17 @@ def example_plot(ax, fontsize=12, nodec=False):
# Spacing with colorbars
# -----------------------
#
# Colorbars still respect the ``w_pad`` and ``h_pad`` values. However they will
# be ``wspace`` and ``hsapce`` apart from other subplots. Note the use of a
# ``pad`` kwarg here in the ``colorbar`` call. It defaults to 0.02 of the size
# Colorbars will be placed ``wspace`` and ``hsapce`` apart from other
# subplots. The padding between the colorbar and the axis it is
# attached to will never be less than ``w_pad`` (for a vertical colorbar)
# or ``h_pad`` (for a horizontal colorbar). Note the use of the ``pad`` kwarg
# here in the ``colorbar`` call. It defaults to 0.02 of the size
# of the axis it is attached to.

fig, axs = plt.subplots(2, 2, constrained_layout=True)
for ax in axs.flatten():
pc = ax.pcolormesh(arr, **pc_kwargs)
fig.colorbar(im, ax=ax, shrink=0.6, pad=0)
fig.colorbar(pc, ax=ax, shrink=0.6, pad=0)
ax.set_xticklabels('')
ax.set_yticklabels('')
fig.set_constrained_layout_pads(w_pad=2./72., h_pad=2./72.,
Expand Down

0 comments on commit 02d7f38

Please sign in to comment.