IPython3 automatically config %matplotlib inline

2019-03-30 18:59发布

问题:

I'm using IPython 3 / Jupyter, and I want to use the %matplotlib option by default.

In IPython 2, I had the next option on the ~/.ipython/profile_default/ipython_notebook_config.py

c.InteractiveShellApp.matplotlib = 'inline'

But in IPython 3, this option is not available anymore.

It also disappeared the setting c.InlineBackend.rc, which I used to set up the appearance of charts.

How those options can be set now?

回答1:

Use the option in ~/.ipython/profile_default/ipython_kernel_config.py



回答2:

  1. Edit file ~/.ipython/profile_default/ipython_config.py

  2. Add line c.InteractiveShellApp.matplotlib = 'inline'

You probably don't have this file, so you can create it with this command

echo "c.InteractiveShellApp.matplotlib = 'inline'" > ipython_config.py

Still works well, as of Apr 2017.



回答3:

Not sure if this works in your case, but you can give it a try:

I am using a custom notebook theme according to this tutorial. Basically, I entered: ipython profile create customcss in a command-line and modified the custom.css file in ~/.ipython/profile_default/static/custom

Additionally i tried to get rid of my personalizations and imports in the first cell of every notebook by writing a file called 00_my_imports.py in the folder ~/.ipython/profile_default/startup.

So in your case, you could try to execute the line '%matplotlib inline' at startup