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

    Click :ref:`here <sphx_glr_download_gallery_userdemo_pgf_fonts.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_userdemo_pgf_fonts.py:


=========
Pgf Fonts
=========





.. image:: /gallery/userdemo/images/sphx_glr_pgf_fonts_001.png
    :class: sphx-glr-single-img





.. code-block:: python


    import matplotlib.pyplot as plt
    plt.rcParams.update({
        "font.family": "serif",
        "font.serif": [],                    # use latex default serif font
        "font.sans-serif": ["DejaVu Sans"],  # use a specific sans-serif font
    })

    plt.figure(figsize=(4.5, 2.5))
    plt.plot(range(5))
    plt.text(0.5, 3., "serif")
    plt.text(0.5, 2., "monospace", family="monospace")
    plt.text(2.5, 2., "sans-serif", family="sans-serif")
    plt.text(2.5, 1., "comic sans", family="Comic Sans MS")
    plt.xlabel("µ is not $\\mu$")
    plt.tight_layout(.5)

    plt.savefig("pgf_fonts.pdf")
    plt.savefig("pgf_fonts.png")


.. _sphx_glr_download_gallery_userdemo_pgf_fonts.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: pgf_fonts.ipynb <pgf_fonts.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>`_
