.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/axes_grid1/simple_colorbar.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_axes_grid1_simple_colorbar.py: =============== Simple Colorbar =============== .. GENERATED FROM PYTHON SOURCE LINES 7-23 .. image-sg:: /gallery/axes_grid1/images/sphx_glr_simple_colorbar_001.png :alt: simple colorbar :srcset: /gallery/axes_grid1/images/sphx_glr_simple_colorbar_001.png, /gallery/axes_grid1/images/sphx_glr_simple_colorbar_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.axes_grid1 import make_axes_locatable ax = plt.subplot() im = ax.imshow(np.arange(100).reshape((10, 10))) # create an Axes on the right side of ax. The width of cax will be 5% # of ax and the padding between cax and ax will be fixed at 0.05 inch. divider = make_axes_locatable(ax) cax = divider.append_axes("right", size="5%", pad=0.05) plt.colorbar(im, cax=cax) plt.show() .. _sphx_glr_download_gallery_axes_grid1_simple_colorbar.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: simple_colorbar.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: simple_colorbar.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_