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

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

.. _sphx_glr_gallery_text_labels_and_annotations_text_fontdict.py:


=======================================================
Controlling style of text and labels using a dictionary
=======================================================

This example shows how to share parameters across many text objects and labels
by creating a dictionary of options passed across several functions.

.. GENERATED FROM PYTHON SOURCE LINES 9-31



.. image-sg:: /gallery/text_labels_and_annotations/images/sphx_glr_text_fontdict_001.png
   :alt: Damped exponential decay
   :srcset: /gallery/text_labels_and_annotations/images/sphx_glr_text_fontdict_001.png, /gallery/text_labels_and_annotations/images/sphx_glr_text_fontdict_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    font = {'family': 'serif',
            'color':  'darkred',
            'weight': 'normal',
            'size': 16,
            }

    x = np.linspace(0.0, 5.0, 100)
    y = np.cos(2*np.pi*x) * np.exp(-x)

    plt.plot(x, y, 'k')
    plt.title('Damped exponential decay', fontdict=font)
    plt.text(2, 0.65, r'$\cos(2 \pi t) \exp(-t)$', fontdict=font)
    plt.xlabel('time (s)', fontdict=font)
    plt.ylabel('voltage (mV)', fontdict=font)

    # Tweak spacing to prevent clipping of ylabel
    plt.subplots_adjust(left=0.15)
    plt.show()


.. _sphx_glr_download_gallery_text_labels_and_annotations_text_fontdict.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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