[IPython-dev] IPython notebook widgets for interactive matplotlib figures

Fernando Perez fperez.net at gmail.com
Tue Jul 29 15:21:07 EDT 2014

On Tue, Jul 29, 2014 at 11:36 AM, Antonino Ingargiola <tritemio at gmail.com>

> Is this the expected behavior? Am I doing something wrong? Is there a way
> I can inhibit the first figure display?

It's an unfortunate side effect of IPython's internal logic that tries to
auto-display plots so that simple calls like


work in an intuitive fashion.  Since you're manually calling display(),
both code paths kick in, and you end up with a duplicate figure.

The simple answer is: in every instance where you're going to do manual
figure displaying yourself, you can prevent the automatic display by putting


at the end of your cell, if you have a handle on a specific figure, or more
simply (if less elegant)


that will close every open figure regardless how many there are or whether
you have a handle on them.

We were never able to come up with a solution that would work well in all
the naive/simple cases and yet also not have funny side effects in more
advanced scenarios like this. In the end, we settled on making the simple
cases work as best as possible, and having to make a manual close() call in
other cases.  It's possible that with a bit more thought a better solution
can be found, this was done early on (before the notebook, all that logic
was designed initially for the Qt console). We had so many things to do
that we moved on with this current solution, but it may be worth revisiting
to see if we can come up with better heuristics or ideas.



Fernando Perez (@fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140729/057bc596/attachment.html>

More information about the IPython-dev mailing list