如何让 python matplotlib mathtext 在 centos7/rhel7 上工作?

how to get python matplotlib mathtext working on centos7/rhel7?

在 centos7/rhel7,我尝试使用文档中的示例做一个简单的绘图:

#!/usr/bin/env python2
import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(10))
plt.title(r'$\alpha > \beta$')
print plt.__version__
plt.show()

我看到的不是 alpha 和 beta 的预期希腊符号:*©@

我不想安装 latex。我不想使用 anaconda python 发行版。

如何让 matplotlib mathtext 在 centos7/rhel7 上运行?

p.s。我试过 plt.rcParams['text.usetext'] = True 但出现 sh latex command not found 错误(latex 显然没有安装)。

简而言之,您不能使用 RPM 安装 matplotlib --> 而是使用 pip 安装版本(matplotlib 版本 2.2.x for python2,matplotlib 版本 >= 3.x python3).

  • 对于 centos7 内置 python2 matplotlib,我认为它是版本 1。2.x 并且它没有很多功能
  • 很可能 python2 matplotlib 是在没有数学的情况下构建的 tex 因为这会显着增加打包的复杂性并显着增加软件部门,因此他们使用了更小的 matplotlib