I would like to remove the italics font that appears when I use subscripts in labels. For example, the "Teff" in the x-label has "eff" in italics. I would like latex not render it in such a way. Generally, in latex this can be achieved with the \rm{} command. However, that does not work in matplotlib. Please help.
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(10)
y = x
plt.plot(x,y,'ro')
plt.xlabel('Primary T$_{eff}$')
NOTE: The code '\033[0m' is used to end the bold and italic text format.
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.
To make a text bold use \textbf command: Some of the \textbf{greatest} discoveries in science were made by accident.
I have encountered this problem many times and it can be solved with this trick
plt.xlabel(r'Primary T$_{\rm eff}$')
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