.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/axes_grid1/demo_fixed_size_axes.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_demo_fixed_size_axes.py: =============================== Axes with a fixed physical size =============================== Note that this can be accomplished with the main library for Axes on Figures that do not change size: :ref:`fixed_size_axes` .. GENERATED FROM PYTHON SOURCE LINES 9-14 .. code-block:: Python import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import Divider, Size .. GENERATED FROM PYTHON SOURCE LINES 15-32 .. code-block:: Python fig = plt.figure(figsize=(6, 6)) # The first items are for padding and the second items are for the axes. # sizes are in inch. h = [Size.Fixed(1.0), Size.Fixed(4.5)] v = [Size.Fixed(0.7), Size.Fixed(5.)] divider = Divider(fig, (0, 0, 1, 1), h, v, aspect=False) # The width and height of the rectangle are ignored. ax = fig.add_axes(divider.get_position(), axes_locator=divider.new_locator(nx=1, ny=1)) ax.plot([1, 2, 3]) .. image-sg:: /gallery/axes_grid1/images/sphx_glr_demo_fixed_size_axes_001.png :alt: demo fixed size axes :srcset: /gallery/axes_grid1/images/sphx_glr_demo_fixed_size_axes_001.png, /gallery/axes_grid1/images/sphx_glr_demo_fixed_size_axes_001_2_00x.png 2.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 33-51 .. code-block:: Python fig = plt.figure(figsize=(6, 6)) # The first & third items are for padding and the second items are for the # axes. Sizes are in inches. h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)] v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)] divider = Divider(fig, (0, 0, 1, 1), h, v, aspect=False) # The width and height of the rectangle are ignored. ax = fig.add_axes(divider.get_position(), axes_locator=divider.new_locator(nx=1, ny=1)) ax.plot([1, 2, 3]) plt.show() .. image-sg:: /gallery/axes_grid1/images/sphx_glr_demo_fixed_size_axes_002.png :alt: demo fixed size axes :srcset: /gallery/axes_grid1/images/sphx_glr_demo_fixed_size_axes_002.png, /gallery/axes_grid1/images/sphx_glr_demo_fixed_size_axes_002_2_00x.png 2.00x :class: sphx-glr-single-img .. _sphx_glr_download_gallery_axes_grid1_demo_fixed_size_axes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_fixed_size_axes.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_fixed_size_axes.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_