
.. 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 <sphx_glr_download_gallery_axes_grid1_demo_fixed_size_axes.py>`
        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])


.. 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()


.. _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 <demo_fixed_size_axes.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: demo_fixed_size_axes.py <demo_fixed_size_axes.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: demo_fixed_size_axes.zip <demo_fixed_size_axes.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
