You just need to have the full expression inside the $
. Basically, you need "meters $10^1$"
. You don't need usetex=True
to do this (or most any mathematical formula).
You may also want to use a raw string (e.g. r""
, vs ""
) to avoid problems with things like
, a
,
,
, f
, etc.
For example:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set(title=r'This is an expression $e^{sin(omegaphi)}$',
xlabel='meters $10^1$', ylabel=r'Hertz $(frac{1}{s})$')
plt.show()
If you don't want the superscripted text to be in a different font than the rest of the text, use mathregular
(or equivalently mathdefault
). Some symbols won't be available, but most will. This is especially useful for simple superscripts like yours, where you want the expression to blend in with the rest of the text.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set(title=r'This is an expression $mathregular{e^{sin(omegaphi)}}$',
xlabel='meters $mathregular{10^1}$',
ylabel=r'Hertz $mathregular{(frac{1}{s})}$')
plt.show()
For more information (and a general overview of matplotlib's "mathtext"), see: http://matplotlib.org/users/mathtext.html
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…