
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/subplots_axes_and_figures/figure_title.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_gallery_subplots_axes_and_figures_figure_title.py>`
        to download the full example code

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

.. _sphx_glr_gallery_subplots_axes_and_figures_figure_title.py:


============
Figure Title
============

Create a figure with separate subplot titles and a centered figure title.

.. GENERATED FROM PYTHON SOURCE LINES 8-35



.. image:: /gallery/subplots_axes_and_figures/images/sphx_glr_figure_title_001.png
    :alt: This is a somewhat long figure title, subplot 1, subplot 2
    :class: sphx-glr-single-img





.. code-block:: default

    import matplotlib.pyplot as plt
    import numpy as np


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

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


    fig, axs = plt.subplots(2, 1, constrained_layout=True)
    axs[0].plot(t1, f(t1), 'o', t2, f(t2), '-')
    axs[0].set_title('subplot 1')
    axs[0].set_xlabel('distance (m)')
    axs[0].set_ylabel('Damped oscillation')
    fig.suptitle('This is a somewhat long figure title', fontsize=16)

    axs[1].plot(t3, np.cos(2*np.pi*t3), '--')
    axs[1].set_xlabel('time (s)')
    axs[1].set_title('subplot 2')
    axs[1].set_ylabel('Undamped')

    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  1.012 seconds)


.. _sphx_glr_download_gallery_subplots_axes_and_figures_figure_title.py:


.. only :: html

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



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

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



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

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


.. only:: html

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

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
