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

Antonino Ingargiola tritemio at gmail.com
Tue Jul 29 16:06:17 EDT 2014


On Tue, Jul 29, 2014 at 12:21 PM, Fernando Perez <fperez.net at gmail.com>
wrote:

>
> On Tue, Jul 29, 2014 at 11:36 AM, Antonino Ingargiola <tritemio at gmail.com>
> wrote:
>
>>
>> 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
>
> plot(x)
>
> 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
>
> plt.close(fig)
>
> at the end of your cell, if you have a handle on a specific figure
>

Ouch! So simple! Thanks for the solution. I didn't tried close() because I
though that closing the figure would destroy it. It turns out that it is
not and the following interact call works as expected.


> 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.
>

Just my 2c: why don't providing an API function like "show_figure(False)".
At this moment it will just call close(). In the future if you change
implementation the API function will stay the same.

Best,
Antonio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140729/e3dd7534/attachment.html>


More information about the IPython-dev mailing list