matplotlib在1.3.0 及更高版本中,一种快速而肮脏的方式,您可以使用Latex \textupand \textbf:
ax.set_ylabel('\textup{Surface Area} (\AA^2)', size =16)
请参阅此处的教程:http: //matplotlib.org/users/usetex.html,不要忘记latex通过以下方式启用:
rc('text', usetex=True)
只要您已Latex安装,这应该适用于旧版本。但如果你想坚持matplotlib's mathtext,也可以这样做:
>>> matplotlib.rcParams['mathtext.fontset']='stixsans'
>>> for i in [1]:
fig, ax = plt.subplots()
ax.plot(data)
ytx=ax.set_ylabel(r'Surface Area $(\AA^2)$', size =16)
并非每种字体都可以使用mathtext,stixsans是“看起来像”的字体:http sans-serif: //matplotlib.org/users/mathtext.html#mathtext-tutorial。老实说,差异非常小。我很确定 Angstrom 不会stixsans将其渲染mathtext为默认Computer Modern字体。
