最近用python的matplotlib设置字体时报错
plt.rcParams['font.sans-serif'] = ['Times New Roman']
findfont: Font family ‘Times New Roman’ not found.
findfont: Generic family ‘sans-serif’ not found because none of the following families were found: Times New Roman
查了下,是字体库的问题。运行以下命令解决:
sudo apt install msttcorefonts -qq
rm ~/.cache/matplotlib -rf
参考资料StackOverflow