在matplotlib中错误的乳胶渲染

时间:2016-09-05 20:21:23

标签: 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

我的乳胶安装功能正常。知道问题是什么吗?

1 个答案:

答案 0 :(得分:0)

您可以在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