Note

Go to the endto download the full example code.

Text and mathtext using pyplot#

Set the special text objectstitle,xlabel, andylabel through the dedicated pyplot functions. Additional textobjects can be placed in the Axes usingtext.

You can use TeX-like mathematical typesetting in all texts; see alsoWriting mathematical expressions.

importmatplotlib.pyplotaspltimportnumpyasnpt=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()
$\mathcal{A}\sin(\omega t)$

References

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

Gallery generated by Sphinx-Gallery