.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/axes_grid1/simple_axes_divider3.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_axes_divider3.py: ===================== Simple axes divider 3 ===================== See also :ref:`axes_grid`. .. GENERATED FROM PYTHON SOURCE LINES 8-45 .. image-sg:: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider3_001.png :alt: simple axes divider3 :srcset: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider3_001.png, /gallery/axes_grid1/images/sphx_glr_simple_axes_divider3_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import Divider import mpl_toolkits.axes_grid1.axes_size as Size fig = plt.figure(figsize=(5.5, 4)) # the rect parameter will be ignored as we will set axes_locator rect = (0.1, 0.1, 0.8, 0.8) ax = [fig.add_axes(rect, label="%d" % i) for i in range(4)] horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])] vert = [Size.AxesY(ax[0]), Size.Fixed(.5), Size.AxesY(ax[2])] # divide the axes rectangle into grid whose size is specified by horiz * vert divider = Divider(fig, rect, horiz, vert, aspect=False) ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0)) ax[1].set_axes_locator(divider.new_locator(nx=2, ny=0)) ax[2].set_axes_locator(divider.new_locator(nx=0, ny=2)) ax[3].set_axes_locator(divider.new_locator(nx=2, ny=2)) ax[0].set_xlim(0, 2) ax[1].set_xlim(0, 1) ax[0].set_ylim(0, 1) ax[2].set_ylim(0, 2) divider.set_aspect(1.) for ax1 in ax: ax1.tick_params(labelbottom=False, labelleft=False) plt.show() .. _sphx_glr_download_gallery_axes_grid1_simple_axes_divider3.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: simple_axes_divider3.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: simple_axes_divider3.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_