You are reading an old version of the documentation (v3.1.1). For the latest version see https://matplotlib.org/stable/gallery/pyplots/pyplot_mathtext.html
Version 3.1.2
matplotlib
Fork me on GitHub

Table of Contents

Related Topics

Pyplot Mathtext

Use mathematical expressions in text labels. For an overview over MathText see Writing mathematical expressions.

import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)

plt.plot(t,s)
plt.title(r'$\alpha_i > \beta_i$', fontsize=20)
plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)
plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$',
         fontsize=20)
plt.xlabel('time (s)')
plt.ylabel('volts (mV)')
plt.show()
../../_images/sphx_glr_pyplot_mathtext_001.png

References

The use of the following functions, methods, classes and modules is shown in this example:

import matplotlib
matplotlib.pyplot.text
matplotlib.axes.Axes.text

Out:

<function Axes.text at 0x7fb11b449378>

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery