[IPython-dev] rant: "%matplotlib inline"

Matthias Bussonnier bussonniermatthias at gmail.com
Thu Jul 2 20:30:38 EDT 2015


Hi William, 

Thanks for your feedback.

> On Jul 2, 2015, at 17:16, William Stein <wstein at gmail.com> wrote:
> 
> <Rant>
> Hi,
> 
> I just want to register my frustration that by far the most common
> support request I get about IPython use in SageMathCloud is the
> following: "To display the plot, I'm tried to pl.show(), and also
> pl.savefig('test.png') as suggested by some answers online, but
> neither did the job. What is the correct command?"
> 
> The answer is "%matplotlib inline", and there is a stackoverflow
> question here about it:
> 
>   http://stackoverflow.com/questions/19410042/how-to-make-ipython-notebook-inline-matplotlib-graphics
> 
> I'm aware that disallowing the `--pylab inline` option when starting
> ipython on the command line was a choice that you made on purpose.

I just want to say that --pylab is deprecated, but --matplotlib still work. 
the only difference is that --matplotlib will just not do all the imports. 

The reason why $ipython notebook --pylab inline , or even $iptyhon notebook --matplotlib inline 
do not work [as expected] is that that these are kernel flags that are passed to the server. It didn’t make sens
to pass them to the kernel as for that we needed to know what flag the kernel can receive. It special case
before, but making ruby kernel crashing, or wondering why some flag would be passed, and some other not. 

So you **can** enable inline by default, you just need to set the default in a config file:

IPKernelApp.matplotlib=<CaselessStrEnum>
    Default: None
    Choices: ['auto', 'gtk', 'gtk3', 'inline', 'nbagg', 'notebook', 'osx', 'qt', 'qt4', 'qt5', 'tk', 'wx']
    Configure matplotlib for interactive use with the default matplotlib
    backend.

We did consider, and are still considering making inline the default, it just break some abstraction
that the kernels need to know they are started from a notebook. 

Hope this will make you life (a bit) easier. You can also modify the kernel spec to add a --matplotlib inline to the argv 
it should  work.

> No response required -- I'm just being a humble tech support person
> watching out for users :-)
> 
> </Rant>

-- 
M




More information about the IPython-dev mailing list