python - matplotlib 中错误的 latex 渲染

标签 python matplotlib latex

使用 python 2.7.12(在 Ubuntu 16.04 上)和 matplotlib 1.5.2,以下代码呈现不正确:

from matplotlib.pyplot import *
plot([1,2],[1,1])
xlabel(r"$\beta+1$")
title(r'$\alpha > \beta$')
show()

xlabel 渲染为 $\partial i\Delta$ 标题渲染为 $\rightharpoonup\Upsilon\partial$看这里: output

我的 latex 安装在其他方面是正常的。知道问题出在哪里吗?

最佳答案

正如您在 User's Guide 中所读到的那样,关于matplotlibrc文件:

# [...] When text.usetex is False,
# font.family may also be one or more concrete font names.

因此,您应该使用具体的 font.family 属性,或者只是将 中的 text.usetex 参数更改为 True matplotlibrc 文件。

#text.usetex     : False  # use latex for all text handling. The following fonts
                          # are supported through the usual rc parameter settings:
                          # new century schoolbook, bookman, times, palatino,
                          # zapf chancery, charter, serif, sans-serif, helvetica,
                          # avant garde, courier, monospace, computer modern roman,
                          # computer modern sans serif, computer modern typewriter
                          # If another font is desired which can loaded using the
                          # LaTeX \usepackage command, please inquire at the
                          # matplotlib mailing list

关于python - matplotlib 中错误的 latex 渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39337229/

相关文章:

python - 如何在绘图中创建非线性轴

latex - BibTeX 在 Texmaker 的 "build"子目录中找不到 .aux 文件

python - 如何通过检查条件来删除 Pandas DataFrame 中的重复项?

python - 使用属性将字典转换为 XML

python - Nosetest初始化错误

latex - 如何在TeX中插入管道符号?

emacs - Flyspell 无法在 emacs 中加载 LaTeX 文件

python - 从 python 调用 C++ 代码以及从 C++ 调用 python 代码

python - 用户警告 : FixedFormatter should only be used together with FixedLocator

python - Matplotlib funcanimation blit 慢