
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/subplots_axes_and_figures/axis_equal_demo.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_subplots_axes_and_figures_axis_equal_demo.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_subplots_axes_and_figures_axis_equal_demo.py:


=======================
Equal axis aspect ratio
=======================

How to set and adjust plots with equal axis aspect ratios.

.. GENERATED FROM PYTHON SOURCE LINES 8-37

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    # Plot circle of radius 3.

    an = np.linspace(0, 2 * np.pi, 100)
    fig, axs = plt.subplots(2, 2)

    axs[0, 0].plot(3 * np.cos(an), 3 * np.sin(an))
    axs[0, 0].set_title('not equal, looks like ellipse', fontsize=10)

    axs[0, 1].plot(3 * np.cos(an), 3 * np.sin(an))
    axs[0, 1].axis('equal')
    axs[0, 1].set_title('equal, looks like circle', fontsize=10)

    axs[1, 0].plot(3 * np.cos(an), 3 * np.sin(an))
    axs[1, 0].axis('equal')
    axs[1, 0].set(xlim=(-3, 3), ylim=(-3, 3))
    axs[1, 0].set_title('still a circle, even after changing limits', fontsize=10)

    axs[1, 1].plot(3 * np.cos(an), 3 * np.sin(an))
    axs[1, 1].set_aspect('equal', 'box')
    axs[1, 1].set_title('still a circle, auto-adjusted data limits', fontsize=10)

    fig.tight_layout()

    plt.show()


.. GENERATED FROM PYTHON SOURCE LINES 38-44

.. tags::

   component: axes
   styling: size
   plot-type: line
   level: beginner


.. _sphx_glr_download_gallery_subplots_axes_and_figures_axis_equal_demo.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: axis_equal_demo.ipynb <axis_equal_demo.ipynb>`

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

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

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

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


.. only:: html

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

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