简体   繁体   English

matplotlib 在 IPython 中不使用 matplotlibrc 文件

[英]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.

相关问题 matplotlib 找不到配置文件 matplotlibrc - matplotlib cannot find configuration file matplotlibrc 是否有一个sympy默认文件,例如matplotlib具有〜/ matplotlib / .matplotlibrc? - Is there a sympy defaults file, like matplotlib has ~/matplotlib/.matplotlibrc? 从matplotlibrc文件加载matplotlib rcparams时,Jupyter Notebook内联绘图中断 - Jupyter notebook inline plotting breaks, when loading matplotlib rcparams from matplotlibrc file Pyinstaller Matplotlib [Errno 2] 没有这样的文件或目录:'C:\\Users\\Tobi\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc' - Pyinstaller Matplotlib [Errno 2] No such file or directory: 'C:\\Users\\Tobi\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc' Matplotlib:有没有办法用 matplotlibrc 设置默认散布 styles? - Matplotlib: Is there a way to set default scatter styles with matplotlibrc? Python,matplotlib使用ipython而不是使用python加载 - Python, matplotlib loads using ipython but not using python Matplotlib保存文件稍后将在ipython中重新编辑 - Matplotlib save file to be reedited later in ipython Matplotlib:将图形另存为 iPython 笔记本中的文件 - Matplotlib: Save figure as file from iPython notebook 使用Pandas或Matplotlib在IPython Notebook中绘制性别图表 - Charting gender in IPython notebook using pandas or matplotlib 在Jupyter iPython Notebook中使用matplotlib绘制图形 - Plotting graph using matplotlib in Jupyter iPython Notebook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM