我无法避免 matplotlib 中关于字体选择的错误。每当我尝试在 Linux 中的远程机器上绘图时,我都会收到以下错误:
/home/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/font_manager.py:1236:
UserWarning: findfont: Font family ['Arial'] not found.
Falling back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext]))
我已经编辑了我的.matplotlibrc
文件(以防万一,在两个位置):
.matplotlib/.matplotlibrc
.config/matplotlib/.matplotlibrc
我在其中添加了以下几行:
backend: Agg
font.family : serif
font.serif : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
font.sans-serif : Helvetica, Avant Garde, Computer Modern Sans serif
font.cursive : Zapf Chancery
font.monospace : Courier, Computer Modern Typewriter
text.usetex : true
不过,matplotlib
一直在抱怨Arial
。为什么?(请注意,这是在使用 运行脚本时python my_script.py
)不涉及 IPython。