.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\python_packages\matplotlib\demo_text_fontdict.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_python_packages_matplotlib_demo_text_fontdict.py: Text fontdict ================ Demo using fontdict to control style of text and labels. .. GENERATED FROM PYTHON SOURCE LINES 6-29 .. image-sg:: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_text_fontdict_001.png :alt: Damped exponential decay :srcset: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_text_fontdict_001.png :class: sphx-glr-single-img .. code-block:: default import numpy as np import matplotlib.pyplot as plt 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() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.428 seconds) .. _sphx_glr_download_11_demos_python_packages_matplotlib_demo_text_fontdict.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_text_fontdict.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_text_fontdict.ipynb `