2015-01-20 73 views
7

我已经安装在我的系统Aria​​l字体:力matplotlibrc使用宋体(字体的路径)

font.sans-serif  : Arial 

如果我检查里面:

/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf 
/usr/share/fonts/truetype/msttcorefonts/arialbi.ttf 
/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf 
/usr/share/fonts/truetype/msttcorefonts/arial.ttf 
/usr/share/fonts/truetype/msttcorefonts/ariali.ttf 
/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf 
/usr/share/fonts/truetype/msttcorefonts/Arial.ttf 
/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf 
/usr/share/fonts/truetype/msttcorefonts/Arial_Black.ttf 
/usr/share/xbmc/media/Fonts/arial.ttf 
/usr/local/share/texmf/fonts/tfm/urw/arial 
/usr/local/share/texmf/fonts/afm/urw/arial 
/usr/local/share/texmf/fonts/vf/urw/arial 
/usr/local/share/texmf/fonts/type1/urw/arial 

我有我的matplotlibrc包括线内改变IPython的:

import matplotlib.pyplot as plt 
plt.plot([1,2,3,4,5,], '*') 
t = plt.ylabel(r'1, 2, 3, 8, 9 6 11 Testing Label') 
print(t.get_fontname()) 

输出是:

myhome/local/lib/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux- 
x86_64.egg/matplotlib/font_manager.py:1279: UserWarning: findfont: Font 
family [u'sans-serif'] not found. Falling back to Bitstream Vera Sans 
(prop.get_family(), self.defaultFamily[fontext])) 

Bitstream Vera Sans 

如何更改此行为并为我的所有地块使用Arial字体? 为什么Arial字体未加载?

有趣的是,如果我使用Seaborn,它将返回Liberation Sans,其中第一个字体(在内部字体列表中)是Arial,第二个是Liberation Sans

+1

这似乎是你的问题在Benjamin Root的matplotlib邮件列表上得到解答。解决方法:“删除字体缓存(通常在〜/ .matplotlib中)。首次使用matplotlib后安装的字体通常永远无法识别。” – 2015-01-21 10:04:55

回答

9

至于建议的@BenjaminRoot删除字体缓存上~/.matplotlib

事实上,在我的Debian系统,与virtualenv中的生态系统内的蟒蛇的东西,这样的文件夹是位于~/.cache/matplotlib/ 我已删除所有文件和文件夹和缓存再次被重新生成。 现在,它的工作! =]