I am finding that TeX messes with my fonts, the alignment of my subplot yaxis labels, etc and I feel like there must be an easier way to get subcripts and superscripts in plot labels. Help!
The Matplotlib also provides a way to write subscripts or superscripts using the dollar sign. To make subscripts, you have to write the expression inside the dollar sign using the _ and ^ symbols. If you use the _ symbol, the superscript will be under the character.
Just use \mathregular{whatever}
in your expression.
For example:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.text(0.2, 0.7, 'No mathtex')
ax.text(0.2, 0.5, 'This superscript $is^{in}$ italics')
ax.text(0.2, 0.3, 'While this $\mathregular{is^{really}}$ the same font')
plt.show()
See http://matplotlib.org/users/mathtext.html for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With