python matplotlib 字体解决
问题描述
- 1. 默认下matplotlib 支持40种基本字体,而不支持如Arial 等
- 2. 生成的svg,eps,pdf 等矢量图形存在字体轮廓化等问题,在AI中不易修改
解决方法:
centos6.5 下解决方案:
- 安装Microsoft TrueType Fonts:
- snippet.bash
wget http://www.itzgeek.com/msttcore-fonts-2.0-3.noarch.rpm rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm
- 清空cache
- snippet.bash
rm -rf ~/.cache/matplotlib/
- 设置matplotlib
- snippet.python
import matplotlib as mpl mpl.rcParams['font.sans-serif'].insert(0, u'Arial') mpl.rcParams['font.family'] = [u'sans-serif',] mpl.rcParams['svg.fonttype'] = 'none'
- 重新生成的图片,字体均为Arial,AI下可编辑