Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove italics in latex subscript in matplotlib

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

like image 674
Rohit Avatar asked Oct 30 '13 00:10

Rohit


People also ask

How do you remove italics in Python?

NOTE: The code '\033[0m' is used to end the bold and italic text format.

How do you make a subscript in Matplotlib?

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.

How do you make text bold in latex?

To make a text bold use \textbf command: Some of the \textbf{greatest} discoveries in science were made by accident.


1 Answers

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

plt.xlabel(r'Primary T$_{\rm eff}$')
like image 124
Brian Avatar answered Oct 01 '22 10:10

Brian