【发布时间】:2014-07-07 01:18:09
【问题描述】:
我尝试导入字体Open Sans over:
import matplotlib as mpl
#update matplotlibrc
mpl.rcParams['font.family'] = 'Open Sans'
#testplot
import matplotlib.pyplot as plt
plt.plot(range(10))
plt.title('Everything is crazy!!!', size=32)
plt.show()
如果我想绘图,matplotlib 找不到字体,给出如下错误消息:
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['Open Sans'] not found. Falling back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext]))
/usr/lib/pymodules/python2.7/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=light:stretch=normal:size=medium. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmb10.ttf
UserWarning)
字体安装在 Ubuntu 中,所有 OpenSans-*.ttf 文件也复制到 matplotlib 文件夹(在 Ubuntu 中为 /usr/share/matplotlib/mpl-data/fonts/ttf/)。 知道如何在 matplotlibrc 中使用字体吗?
【问题讨论】:
-
是以下目录之一中存在的字体: /usr/X11R6/lib/X11/fonts/TTF/ /usr/X11/lib/X11/fonts /usr/share/fonts/ / usr/local/share/fonts/ /usr/lib/openoffice/share/fonts/truetype/
-
我把它复制到 /usr/share/fonts/truetype 什么都没发生
标签: python ubuntu fonts matplotlib