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

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

.. _sphx_glr_gallery_pyplots_pyplot_two_subplots.py:


=========================
Two subplots using pyplot
=========================

Create a figure with two subplots using `.pyplot.subplot`.

.. GENERATED FROM PYTHON SOURCE LINES 8-29

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np


    def f(t):
        return np.exp(-t) * np.cos(2*np.pi*t)


    t1 = np.arange(0.0, 5.0, 0.1)
    t2 = np.arange(0.0, 5.0, 0.02)

    plt.figure()
    plt.subplot(211)
    plt.plot(t1, f(t1), color='tab:blue', marker='o')
    plt.plot(t2, f(t2), color='black')

    plt.subplot(212)
    plt.plot(t2, np.cos(2*np.pi*t2), color='tab:orange', linestyle='--')
    plt.show()




.. image-sg:: /gallery/pyplots/images/sphx_glr_pyplot_two_subplots_001.png
   :alt: pyplot two subplots
   :srcset: /gallery/pyplots/images/sphx_glr_pyplot_two_subplots_001.png, /gallery/pyplots/images/sphx_glr_pyplot_two_subplots_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 30-37

.. admonition:: References

   The use of the following functions, methods, classes and modules is shown
   in this example:

   - `matplotlib.pyplot.figure`
   - `matplotlib.pyplot.subplot`


.. _sphx_glr_download_gallery_pyplots_pyplot_two_subplots.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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