import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = 'simHei'
显而易见,这个字体在我的arch环境中是完全不存在的,这也导致在运行程序时报错
1 2 3 4 5 6 7 8 9 10 11 12
findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei findfont: Generic family 'sans-serif' not found because none of the following families were found: simHei ...
/usr/share/fonts/wenquanyi/wqy-zenhei/wqy-zenhei.ttc: WenQuanYi Zen Hei Mono,文泉驛等寬正黑,文泉驿等宽正黑:style=Regular /usr/share/fonts/wenquanyi/wqy-zenhei/wqy-zenhei.ttc: WenQuanYi Zen Hei Sharp,文泉驛點陣正黑,文泉驿点阵正黑:style=Regular /usr/share/fonts/wenquanyi/wqy-zenhei/wqy-zenhei.ttc: WenQuanYi Zen Hei,文泉驛正黑,文泉驿正黑:style=Regular
我选择在matplotlib中使用的字体名称为WenQuanYi Zen Hei
需要注意的是,matplotlib报错提示缺失的字体族为sans-serif,即无衬线字体。
所以实际上我不能选择WenQuanYi Zen Hei Mono(等宽字体)和WenQuanYi Zen Hei Sharp。(但是我也不确定,但是尝试这两个字体会报错)