[英]matplotlib not using matplotlibrc file in IPython
I recently upgraded from matplotlib v1.5.3 from v2.0.0, but with this change, it seems that matplotlib no longer uses my edited matplotlibrc file when plotting figures.我最近从 v2.0.0 升级了 matplotlib v1.5.3,但是有了这个变化,matplotlib 在绘制图形时似乎不再使用我编辑过的 matplotlibrc 文件。 When I open the matplotlibrc file, I see that my changes are in fact implemented, but when I type
matplotlib.rcParams
, these changes are not displayed.当我打开 matplotlibrc 文件时,我看到我的更改实际上已经实现,但是当我输入
matplotlib.rcParams
,这些更改没有显示。 Thinking that maybe it was looking at a different matplotlibrc file, I ran matplotlib.matplotlib_fname()
, but this points to the same directory of my edited matplotlibrc file.考虑到它可能正在查看不同的 matplotlibrc 文件,我运行了
matplotlib.matplotlib_fname()
,但这指向我编辑过的 matplotlibrc 文件的同一目录。
Does anyone know what's going on here?有谁知道这里发生了什么?
FYI, I am running matplotlib 2.0.0 in Python 2.7.12 with IPython 5.1.0.仅供参考,我正在使用 IPython 5.1.0 在 Python 2.7.12 中运行 matplotlib 2.0.0。 To open matplotlib in IPython, I utilize first the command
%matplotlib
.要在 IPython 中打开 matplotlib,我首先使用命令
%matplotlib
。
In matplotlib 2.0.0, the default location on Linux for the matplotlibrc
file has moved from在 matplotlib 2.0.0 中,
matplotlibrc
文件在 Linux 上的默认位置已从
~/.matplotlib/matplotlibrc
to到
~/.config/matplotlib/matplotlibrc
Try moving your customised file to there and see if it works.尝试将您的自定义文件移动到那里,看看它是否有效。 That worked for me when I moved from 1.5.3 to 2.0.0.
当我从 1.5.3 迁移到 2.0.0 时,这对我有用。
See the docs for more info on how it finds the right matplotlibrc file.有关如何找到正确的 matplotlibrc 文件的更多信息,请参阅文档。
For me, the problem was that the matplotlibrc was working, then iPython was overriding it at the end of the cell.对我来说,问题是 matplotlibrc正在工作,然后 iPython 在单元格的末尾覆盖了它。 The way to check for this is to import matplotlib and print the
plt.rcParams
dict in the same cell, then run the same cell again.检查这一点的方法是导入 matplotlib 并在同一个单元格中打印
plt.rcParams
dict,然后再次运行同一个单元格。 If it changes between calls, iPython is overriding it.如果它在调用之间发生变化,iPython 将覆盖它。
The fix is to add解决方法是添加
c.InteractiveShellApp.matplotlib = 'inline'
c.InlineBackend.rc = {}
to your ipython_config.py
.到您的
ipython_config.py
。 The second line tells iPython not to update the rParams dict.第二行告诉 iPython 不要更新 rParams dict。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.