remove italics in latex subscript in matplotlib

一曲冷凌霜 提交于 2019-12-05 16:21:25

问题


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


回答1:


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

plt.xlabel(r'Primary T$_{\rm eff}$')


来源:https://stackoverflow.com/questions/19671659/remove-italics-in-latex-subscript-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!