我想弄清楚如何获得在python matplotlib中工作的mathtext。matplotlib mathtext找不到字体
他们提供一些small example code我所抄录如下:
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t,s)
plt.title(r'$\alpha_i > \beta_i$', fontsize=20)
plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)
plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$',
fontsize=20)
plt.xlabel('time (s)')
plt.ylabel('volts (mV)')
plt.show()
当我尝试运行这段代码,我得到很多的警告看起来像这样: /usr/lib/python2.7/site-packages/matplotlib/font_manager.py:1242: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext]))
和mathtext没有按” t正确渲染。这个数字看起来是这样的:
当它应该是这样的:
尝试清除matplotlib'd字体缓存 – 2013-03-01 01:12:44
什么是你的系统和python的版本和matplotlib你使用? – 2013-03-01 08:12:17
@DavidZwicker fedora 14,python 2.7,python-matplotlib-1.0.1-12.fc14.i686 – Joe 2013-03-01 22:13:37