admin管理员组

文章数量:1594755

1. 将 times.ttf,timesbd.ttf,timesbi.ttf,timesi.ttf 字体文件放置如下目录下:

        ~/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf

 注:~/ 指当前python环境所在目录

2. 清除Linux下的 matplotlib 缓存

cd ~/.cache/matplotlib
rm * -r

3. 在用 matplotlib 绘图前添加如下代码:

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman']
 

附:times.ttf 等字体文件获取

链接:https://pan.baidu/s/1AhxLIIVRiM29f1jf0w2Jww 
提取码:1234

本文标签: 操作系统字体LinuxmatplotlibRoman