File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -284,20 +284,34 @@ Colorbar
284284
285285If you create colorbar with :func: `~matplotlib.pyplot.colorbar `
286286command, the created colorbar is an instance of Axes not Subplot, thus
287- tight_layout does not work. One option is to use AxesGrid1 toolkit to explicitly create an axes for colorbar.
287+ tight_layout does not work. With Matplotlib v1.1, you may create a
288+ colobar as a subplot using the gridspec.
288289
289290.. plot ::
290291 :include-source:
291292 :context:
292293
293294 plt.close('all')
294295 fig = plt.figure(figsize=(4, 4))
296+ im = plt.imshow(arr, interpolation="none")
297+
298+ plt.colorbar(im, use_gridspec=True)
299+
300+ plt.tight_layout()
301+
302+ Another option is to use AxesGrid1 toolkit to
303+ explicitly create an axes for colorbar.
295304
296- ax = plt.subplot(111)
305+ .. plot ::
306+ :include-source:
307+ :context:
308+
309+ plt.close('all')
310+ fig = plt.figure(figsize=(4, 4))
297311 im = plt.imshow(arr, interpolation="none")
298312
299313 from mpl_toolkits.axes_grid1 import make_axes_locatable
300- divider = make_axes_locatable(ax )
314+ divider = make_axes_locatable(plt.gca() )
301315 cax = divider.append_axes("right", "5%", pad="3%")
302316 plt.colorbar(im, cax=cax)
303317
You can’t perform that action at this time.
0 commit comments