.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/pyplots/pyplot_text.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_pyplots_pyplot_text.py: ============================== Text and mathtext using pyplot ============================== Set the special text objects `~.pyplot.title`, `~.pyplot.xlabel`, and `~.pyplot.ylabel` through the dedicated pyplot functions. Additional text objects can be placed in the axes using `~.pyplot.text`. You can use TeX-like mathematical typesetting in all texts; see also :ref:`mathtext`. .. redirect-from:: /gallery/pyplots/pyplot_mathtext .. GENERATED FROM PYTHON SOURCE LINES 15-29 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np t = np.arange(0.0, 2.0, 0.01) s = np.sin(2*np.pi*t) plt.plot(t, s) plt.text(0, -1, r'Hello, world!', fontsize=15) plt.title(r'$\mathcal{A}\sin(\omega t)$', fontsize=20) plt.xlabel('Time [s]') plt.ylabel('Voltage [mV]') plt.show() .. image-sg:: /gallery/pyplots/images/sphx_glr_pyplot_text_001.png :alt: $\mathcal{A}\sin(\omega t)$ :srcset: /gallery/pyplots/images/sphx_glr_pyplot_text_001.png, /gallery/pyplots/images/sphx_glr_pyplot_text_001_2_00x.png 2.00x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 30-41 .. admonition:: References The use of the following functions, methods, classes and modules is shown in this example: - `matplotlib.pyplot.hist` - `matplotlib.pyplot.xlabel` - `matplotlib.pyplot.ylabel` - `matplotlib.pyplot.text` - `matplotlib.pyplot.grid` - `matplotlib.pyplot.show` .. _sphx_glr_download_gallery_pyplots_pyplot_text.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: pyplot_text.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: pyplot_text.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_