<分区> 分区>
我尝试在 matplotlib 绘图中使用 LaTeX 标签,但它们的编译不一致。在下面的屏幕截图中,您可以看到,不仅轴的标签,而且并非所有 x 和 y 刻度都在 LaTeX 中呈现。
上图的 MWE 由下式给出
#!/usr/bin/python3
import matplotlib.pyplot as plt
fig = plt.figure()
axes = fig.add_axes([0.1, 0.1, 0.8, 0.8])
# FONT
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.xlabel(r'$y$', fontsize=18)
plt.ylabel(r'$x$',fontsize=18)
# PLOT
axes.plot([1,2,3], [1,4,9], label=r'$x^2$')
# LEGEND
axes.legend(numpoints=1, loc=1, prop={'size':15})
plt.show()
我在安装了 TeX Live 2018 的 Debian 系统和 macOS 上进行了尝试。
如何让 LaTeX 一致地呈现所有标签?
(注:最后我想用Fourier作为数学字体,ebgaramond作为文字字体)
