【问题标题】:how to get python matplotlib mathtext working on centos7/rhel7?如何让 python matplotlib mathtext 在 centos7/rhel7 上工作?
【发布时间】:2019-07-04 15:02:44
【问题描述】:

在 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()
  • matplotlib.__version__ 显示 1.2.0(从 RPM 安装)。
  • plt.rcParams['text.usetext'] 设置为 False

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

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

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

附言我尝试了plt.rcParams['text.usetext'] = True,但得到了sh latex command not found 错误(latex 显然没有安装)。

【问题讨论】:

  • from matplotlib import rc ; rc('text', usetex=False)
  • @gboffi 我想我的书面问题不清楚。让我澄清一下。当我将rcParams['text.usetex'] 设置为False 时,我得到*©@

标签: python matplotlib centos7 rhel7


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2016-02-19
    • 1970-01-01
    • 2017-01-29
    • 2022-08-13
    • 1970-01-01
    • 2015-10-01
    • 2016-07-08
    • 1970-01-01
    • 2017-08-31
    相关资源
    最近更新 更多