English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
You can put TeX markup for a subset of a Matplotlib text string inside a pair of dollar signs ($).
# Filename : example.py # Copyright : 2020 By w3codebox # Author by : www.oldtoolbag.com # Date : 2020-08-08 # math text plt.title(r'$\alpha > \beta$') )
To create subscripts and superscripts, please use the _ and ^ symbols -
r'$\alpha_i> \beta_i$' 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(0.6, 0.6, r'$\mathcal{A}\sin(2 \omega t)$', fontsize= 20) plt.text(0.1, -0.5, r'$\sqrt{2}$', fontsize=10) plt.xlabel('time (s)') plt.ylabel('volts (mV)') plt.show()
Execute the above example code to get the following result -