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

MinRK benjaminrk at gmail.com
Mon Jul 6 15:13:58 EDT 2015


On Mon, Jul 6, 2015 at 10:13 AM, Doug Blank <doug.blank at gmail.com> wrote:

On Mon, Jul 6, 2015 at 1:03 PM, Thomas Kluyver <takowl at gmail.com> wrote:
>
>> On 6 July 2015 at 09:37, MinRK <benjaminrk at gmail.com> wrote:
>>
>>> I think it should be IPython's responsibility to detect matplotlib's
>>> import and register the inline backend.
>>
>>
>> This seems reasonable, but looking at the docs, I realise I'm not
>> actually sure how to register a hook to fire after an import. There's
>> plenty of machinery for intercepting imports to provide a module in some
>> other way, but nothing obvious for detecting that an import has happened.
>> PEP 369, post import hooks, was withdrawn years ago.
>>
>> I guess we'd need to override __import__(), but that feels rather wrong.
>>
>
> Can this be solved in a manner that could also work for other kernels? Not
> the exact same code, but a general principle.
>
> Perhaps thinking of it as a general "handshaking" issue... the kernel and
> the initiating front need to have a conversation about a variety of
> settings, and the result is the understanding of what format certain things
> will take.
>
I don’t think so, or at least not the behavior I am proposing. I am *not*
proposing an alternative to --matplotlib inline, which imports and enables
inline matplotlib at startup for all kernels. I think we should not do this
because it slows kernel startup, and gets in the way if people want to to
different things with matplotlib (it may be appropriate for certain hosted
environments, especially while the default behavior is so problematic).
Instead, I am proposing a way for import matplotlib.pyplot to ‘just work’
in the notebook, just as it does in the terminal, by making inline
matplotlib the default in that case if %matplotlib has not already been
called beforehand. This is a 100% IPython + matplotlib behavior, and not
generic to other kernels.

Having something generic, like ‘arguments passed to the kernel’ (to be
generic, I do not think it should go beyond extra CLI arguments and/or
environment variables) is perhaps appropriate, but not how we should fix
the issue at hand.

-MinRK


> Maybe a general %setup or %config concept could be used.
>
> -Doug
>
>
>>
>>
>> Thomas
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
> _______________________________________________
> 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/20150706/06aa78d4/attachment.html>


More information about the IPython-dev mailing list