【发布时间】:2014-01-10 10:11:03
【问题描述】:
以下脚本:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as mpl
mpl.rc('font', family='sans-serif')
mpl.rc('text', usetex=True)
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.text(0.2,0.5,r"Math font: $451^\circ$")
ax.text(0.2,0.7,r"Normal font (except for degree symbol): 451$^\circ$")
fig.savefig('test.png')
尝试在 matplotlib 中使用 sans-serif 字体和 LaTeX。问题是数学字体仍然是衬线字体(如轴号所示,如中心标签所示)。有没有办法将数学字体设置为无衬线?
【问题讨论】:
-
您可能想查看github.com/nschloe/matplotlib2tikz。此外,matplotlib 最近配备了 TikZ/PGF 后端,参见。 github.com/matplotlib/matplotlib/issues/319.
-
我下面的回答有用吗?
标签: python latex matplotlib