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

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

.. _sphx_glr_gallery_text_labels_and_annotations_mathtext_demo.py:


========
Mathtext
========

Use Matplotlib's internal LaTeX parser and layout engine.  For true LaTeX
rendering, see the text.usetex option.

.. GENERATED FROM PYTHON SOURCE LINES 9-27



.. image-sg:: /gallery/text_labels_and_annotations/images/sphx_glr_mathtext_demo_001.png
   :alt: $\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} \Delta_{i+1}^j$
   :srcset: /gallery/text_labels_and_annotations/images/sphx_glr_mathtext_demo_001.png, /gallery/text_labels_and_annotations/images/sphx_glr_mathtext_demo_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt

    fig, ax = plt.subplots()

    ax.plot([1, 2, 3], label=r'$\sqrt{x^2}$')
    ax.legend()

    ax.set_xlabel(r'$\Delta_i^j$', fontsize=20)
    ax.set_ylabel(r'$\Delta_{i+1}^j$', fontsize=20)
    ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} '
                 r'\Delta_{i+1}^j$', fontsize=20)

    tex = r'$\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\sin(2 \pi f x_i)$'
    ax.text(1, 1.6, tex, fontsize=20, va='bottom')

    fig.tight_layout()
    plt.show()


.. _sphx_glr_download_gallery_text_labels_and_annotations_mathtext_demo.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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