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

Adam Hughes hughesadam87 at gmail.com
Fri Jul 3 13:38:23 EDT 2015


To bike shed, when I teach classes with notebooks, I typically distribute a
template notebook that already has a few cells pre-filled.  This includes
the %matpotlib inline and other matplotlib configurations, as well as some
javascript to change the style of the notebooks.

Having students use these templated notebooks instead of a blank notebook
usually is easier than trying to configure matplotlib and ipython on their
machines.

On Fri, Jul 3, 2015 at 1:32 PM, Brian Blais <bblais at gmail.com> wrote:

> I'll continue the rant, and perhaps add a bit of a suggestion.  I come
> at this from an instructor of scientific methods, usually with
> students with no programming or command line experience - typically
> windows.  The arcane syntax (from a beginner's perspective) of
> %matplotlib inline seems to just add confusion - even while I
> understand the motivation.  In the past, it was easy enough to slap
> the command line option in the shortcut once and be done with it.
> asking the students to manually edit the IPython config files is a bit
> much for them, and in windows who knows where it is.
>
> One possible solution, which may work to solve this is to have a
> (double-clickable) app to set some of the standard defaults, modifying
> the config files programmatically.  that way, there is one easy set up
> step after install and the problem is solved without resorting to
> command-line arguments, manually editing the config files, or manually
> importing the library in each and every notebook.
>
> thanks,
>
> Brian Blais
>
>
> On Thu, Jul 2, 2015 at 8:30 PM, Matthias Bussonnier
> <bussonniermatthias at gmail.com> wrote:
> > 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
> >
> > _______________________________________________
> > IPython-dev mailing list
> > IPython-dev at scipy.org
> > http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
>
> --
> -----------------
>
>              bblais at gmail.com
>              http://web.bryant.edu/~bblais
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150703/e196fbec/attachment.html>


More information about the IPython-dev mailing list