我使用MikTeX并尝试在我的matplotlib图中获取LaTeX字体。
然而,使用demo代码,Jyputer Notebook说没有latex,
Failed to process string with tex because latex could not be found我尝试在PATH中添加latex.exe、dvipng.exe和ghostscript的路径。不幸的是,它仍然不能工作。我做错了什么?
如果我评估以下内容
import matplotlib.pyplot as plt
import numpy as np
plt.plot(np.sin(np.arange(0, 10, 0.1)),label=r"$\mathcal{M}=2$")
plt.xlabel("x")
plt.ylabel("y")
plt.legend()它会返回给我下一张图片,

所以,我看到\mathcal{}命令工作得很好,而字体不是"latex“。
发布于 2020-10-07 16:59:02
您需要添加plt.rc('text', usetex=True)。
https://stackoverflow.com/questions/64240196
复制相似问题