.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/axes_grid1/simple_axes_divider1.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_divider1.py: ===================== Simple Axes Divider 1 ===================== See also :ref:`axes_grid`. .. GENERATED FROM PYTHON SOURCE LINES 8-22 .. code-block:: Python import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import Divider, Size def label_axes(ax, text): """Place a label at the center of an Axes, and remove the axis ticks.""" ax.text(.5, .5, text, transform=ax.transAxes, horizontalalignment="center", verticalalignment="center") ax.tick_params(bottom=False, labelbottom=False, left=False, labelleft=False) .. GENERATED FROM PYTHON SOURCE LINES 23-24 Fixed axes sizes; fixed paddings. .. GENERATED FROM PYTHON SOURCE LINES 24-46 .. code-block:: Python fig = plt.figure(figsize=(6, 6)) fig.suptitle("Fixed axes sizes, fixed paddings") # Sizes are in inches. horiz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), Size.Fixed(.5)] vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)] rect = (0.1, 0.1, 0.8, 0.8) # Divide the axes rectangle into a grid with sizes specified by horiz * vert. div = Divider(fig, rect, horiz, vert, aspect=False) # The rect parameter will actually be ignored and overridden by axes_locator. ax1 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0)) label_axes(ax1, "nx=0, ny=0") ax2 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2)) label_axes(ax2, "nx=0, ny=2") ax3 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2)) label_axes(ax3, "nx=2, ny=2") ax4 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0)) label_axes(ax4, "nx=2, nx1=4, ny=0") .. image-sg:: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_001.png :alt: Fixed axes sizes, fixed paddings :srcset: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_001.png, /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_001_2_00x.png 2.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 47-48 Axes sizes that scale with the figure size; fixed paddings. .. GENERATED FROM PYTHON SOURCE LINES 48-70 .. code-block:: Python fig = plt.figure(figsize=(6, 6)) fig.suptitle("Scalable axes sizes, fixed paddings") horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), Size.Scaled(.5)] vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)] rect = (0.1, 0.1, 0.8, 0.8) # Divide the axes rectangle into a grid with sizes specified by horiz * vert. div = Divider(fig, rect, horiz, vert, aspect=False) # The rect parameter will actually be ignored and overridden by axes_locator. ax1 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0)) label_axes(ax1, "nx=0, ny=0") ax2 = fig.add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2)) label_axes(ax2, "nx=0, ny=2") ax3 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2)) label_axes(ax3, "nx=2, ny=2") ax4 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0)) label_axes(ax4, "nx=2, nx1=4, ny=0") plt.show() .. image-sg:: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_002.png :alt: Scalable axes sizes, fixed paddings :srcset: /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_002.png, /gallery/axes_grid1/images/sphx_glr_simple_axes_divider1_002_2_00x.png 2.00x :class: sphx-glr-single-img .. _sphx_glr_download_gallery_axes_grid1_simple_axes_divider1.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_divider1.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: simple_axes_divider1.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_