.. _sphx_glr_gallery_text_labels_and_annotations_mathtext_demo.py: ============= Mathtext Demo ============= Use matplotlib's internal LaTeX parser and layout engine. For true latex rendering, see the text.usetex option .. image:: /gallery/text_labels_and_annotations/images/sphx_glr_mathtext_demo_001.png :align: center .. code-block:: python import numpy as np from matplotlib.pyplot import figure, show fig = figure() fig.subplots_adjust(bottom=0.2) ax = fig.add_subplot(111) ax.plot([1, 2, 3], 'r') x = np.arange(0.0, 3.0, 0.1) ax.grid(True) ax.set_xlabel(r'$\Delta_i^j$', fontsize=20) ax.set_ylabel(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') ax.legend([r"$\sqrt{x^2}$"]) ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} ' r'\Delta_{i+1}^j$', fontsize=20) show() **Total running time of the script:** ( 0 minutes 0.019 seconds) .. only :: html .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: mathtext_demo.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: mathtext_demo.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_