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

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

.. _sphx_glr_gallery_subplots_axes_and_figures_share_axis_lims_views.py:


===========================
Share axis limits and views
===========================

It's common to make two or more plots which share an axis, e.g., two subplots
with time as a common axis.  When you pan and zoom around on one, you want the
other to move around with you.  To facilitate this, matplotlib Axes support a
``sharex`` and ``sharey`` attribute.  When you create a `~.pyplot.subplot` or
`~.pyplot.axes`, you can pass in a keyword indicating what Axes you want to
share with.

.. GENERATED FROM PYTHON SOURCE LINES 13-27

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    t = np.arange(0, 10, 0.01)

    ax1 = plt.subplot(211)
    ax1.plot(t, np.sin(2*np.pi*t))

    ax2 = plt.subplot(212, sharex=ax1)
    ax2.plot(t, np.sin(4*np.pi*t))

    plt.show()


.. GENERATED FROM PYTHON SOURCE LINES 28-33

.. tags::

   component: axis
   plot-type: line
   level: beginner


.. _sphx_glr_download_gallery_subplots_axes_and_figures_share_axis_lims_views.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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