23

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}$')

enter image description here

Rohit
  • 5,840
  • 13
  • 42
  • 65

1 Answers1

31

I have encountered this problem many times and it can be solved with this trick

plt.xlabel(r'Primary T$_{\rm eff}$')
sodd
  • 12,482
  • 3
  • 54
  • 62
Brian
  • 13,996
  • 19
  • 70
  • 94