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

.. only:: html

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

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

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

.. _sphx_glr_gallery_userdemo_pgf_preamble_sgskip.py:


============
Pgf Preamble
============

.. GENERATED FROM PYTHON SOURCE LINES 7-34

.. code-block:: default


    import matplotlib as mpl
    mpl.use("pgf")
    import matplotlib.pyplot as plt
    plt.rcParams.update({
        "font.family": "serif",  # use serif/main font for text elements
        "text.usetex": True,     # use inline math for ticks
        "pgf.rcfonts": False,    # don't setup fonts from rc parameters
        "pgf.preamble": "\n".join([
             r"\usepackage{url}",            # load additional packages
             r"\usepackage{unicode-math}",   # unicode math setup
             r"\setmainfont{DejaVu Serif}",  # serif font via preamble
        ])
    })

    fig, ax = plt.subplots(figsize=(4.5, 2.5))

    ax.plot(range(5))

    ax.set_xlabel("unicode text: я, ψ, €, ü")
    ax.set_ylabel(r"\url{https://matplotlib.org}")
    ax.legend(["unicode math: $λ=∑_i^∞ μ_i^2$"])

    fig.tight_layout(pad=.5)

    fig.savefig("pgf_preamble.pdf")
    fig.savefig("pgf_preamble.png")


.. _sphx_glr_download_gallery_userdemo_pgf_preamble_sgskip.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: pgf_preamble_sgskip.py <pgf_preamble_sgskip.py>`



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

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