matplotlib not using matplotlibrc file in IPython

对着背影说爱祢 提交于 2020-01-15 09:16:09

问题


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. 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. 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.

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. To open matplotlib in IPython, I utilize first the command %matplotlib.


回答1:


In matplotlib 2.0.0, the default location on Linux for the matplotlibrc file has moved from

~/.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.

See the docs for more info on how it finds the right matplotlibrc file.




回答2:


For me, the problem was that the matplotlibrc was working, then iPython was overriding it at the end of the cell. 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. If it changes between calls, iPython is overriding it.

The fix is to add

c.InteractiveShellApp.matplotlib = 'inline'
c.InlineBackend.rc = {}

to your ipython_config.py. The second line tells iPython not to update the rParams dict.



来源:https://stackoverflow.com/questions/41862315/matplotlib-not-using-matplotlibrc-file-in-ipython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!