python - 在 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)
解决方案
我会仔细检查乳胶是否在你的路上。看到它找不到是什么让我怀疑可能是这种情况。我还会检查其他依赖项是否也存在。
推荐阅读
- c++ - 继承泛型成员函数
- python - 在表格中使用 for 循环格式化 API 列表
- vue.js - 我如何使用离子模态控制器捕获模态 this.$emit
- sql - 当单个组中有多个元素并且每个元素具有唯一值时如何在 SQL Server 中重塑数据
- jquery - JQuery 停止任何其他事件和函数,直到此事件完成
- javascript - 如何访问已动态传递的嵌套对象属性的值?
- arrays - 从数组中定义对象的键类型
- google-apps-script - 我正在寻找改进用于复制数据的代码
- mysql - 如何使用 liquibase 和 mysql 创建触发器来修复 SQL 语法错误
- azure - AZURE AD 中的 API 权限(7 月 19 日版本)