首页 > 解决方案 > 在 python 中安装 Latex 以更改绘图的字体

问题描述

我正在使用 IDE Spyder,需要将绘图上的字体更改为与 Latex 使用的相同。我看过以下说明:

Matplotlib 的 LaTeX 支持需要工作的 LaTeX 安装、dvipng(可能包含在您的 LaTeX 安装中)和 Ghostscript(建议使用 GPL Ghostscript 8.60 或更高版本)。这些外部依赖项的可执行文件必须全部位于您的 PATH 中。

但是你怎么做呢?现在我收到错误

Failed to process string with tex because latex could not be found

使用:

mpl.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
mpl.rc('text', usetex=True)

标签: pythonmatplotliblatextex

解决方案


我会仔细检查乳胶是否在你的路上。看到它找不到是什么让我怀疑可能是这种情况。我还会检查其他依赖项是否也存在。


推荐阅读