在 matplotlib 中禁用 tex 解释器
Disable tex interpreter in matplotlib
我想使用 matplotlib(通过安装在 os x yosemite 上的 anaconda-spider)制作绘图,并在其上放置不被 tex 解释的标签。
这是示例代码:
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pp
my_rc_param = {'text.usetex': False}
pp.figure()
pp.rcParams.update(my_rc_param)
pp.plot(range(10))
pp.xlabel('$x$')
我想准确地看到字符串 $x$ 作为 x 标签。反过来,我得到了数学模式乳胶 x。
我也试过,但没有成功,把下面的序言:
from matplotlib import rc
rc('text', usetex=False)
有没有办法强制使用普通解释器?
还是我应该将其视为错误?
您没有获得任何 Latex 模式。您只是在使用 mathtex feature of matplotlib. Using latex is a different thing. I checked whether it is possible to switch off mathtex for matplotlib, and there is a quiet recent issue on this (see here)。然而,解决这个问题的方法是避免数学只是用 '\':
转义 $ 符号
pp.xlabel('$x$')
只需删除与 text.usetex 相关的所有内容,因为您要在这里做完全不同的事情。
我想使用 matplotlib(通过安装在 os x yosemite 上的 anaconda-spider)制作绘图,并在其上放置不被 tex 解释的标签。 这是示例代码:
# -*- coding: utf-8 -*-
import matplotlib.pyplot as pp
my_rc_param = {'text.usetex': False}
pp.figure()
pp.rcParams.update(my_rc_param)
pp.plot(range(10))
pp.xlabel('$x$')
我想准确地看到字符串 $x$ 作为 x 标签。反过来,我得到了数学模式乳胶 x。 我也试过,但没有成功,把下面的序言:
from matplotlib import rc
rc('text', usetex=False)
有没有办法强制使用普通解释器? 还是我应该将其视为错误?
您没有获得任何 Latex 模式。您只是在使用 mathtex feature of matplotlib. Using latex is a different thing. I checked whether it is possible to switch off mathtex for matplotlib, and there is a quiet recent issue on this (see here)。然而,解决这个问题的方法是避免数学只是用 '\':
转义 $ 符号pp.xlabel('$x$')
只需删除与 text.usetex 相关的所有内容,因为您要在这里做完全不同的事情。