Python Matplotlib不侦听字体选择

Python Matplotlib不侦听字体选择,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,我无法避免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.

我无法避免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

来自

text.usetex为True时不支持实字体名称


如果你想使用TeX,也许你应该使用像“serif”、“sans serif”、“草书”、“fantasy”或“monospace”这样的字体系列。

如果你使用的是seaborn,但没有安装Arial,这将发生(实际上我目前正在改进这项工作)。目前最好的解决办法是打电话

sns.set(font="serif")

在导入seaborn之后和绘图之前。

谢谢,尽管我不确定是否遵循。我在哪里没有像你提到的那样指定字体系列?我需要在我的
.matplotlibrc
中更改哪些内容?查看指定为“Arial”的代码会很有帮助。我不是自己设置的。我想知道这是否来自导入
seaborn
。seaborn确实覆盖了字体@User815423426添加了seaborn标记。如果您不使用straight matplotlib,您应该指出您正在使用的扩展层。谢谢——从那时起有解决方案吗?我最近从master升级了
seaborn
,但没有成功。不幸的是,我最终将问题归结为matplotlib中的一个bug。它应该在1.4中修复…什么是sns?如果在我的系统上可用,我将如何设置Arial?