[IPython-dev] IPython notebook widgets for interactive matplotlib figures
Antonino Ingargiola
tritemio at gmail.com
Tue Jul 29 17:11:06 EDT 2014
On Tue, Jul 29, 2014 at 1:41 PM, Fernando Perez <fperez.net at gmail.com>
wrote:
>
> On Tue, Jul 29, 2014 at 1:06 PM, Antonino Ingargiola <tritemio at gmail.com>
> wrote:
>
>> 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.
>
>
> Not a bad idea... I'd like to mull a little bit on the cleanest way to do
> this, but that's not a bad solution.
>
> If nothing else, you can add that to your local utils for now, and see if
> it works well enough.
>
> def showfig(f):
> plt.close(f)
> display(f)
>
> is easy enough to add at the top :)
>
Yep, I'm doing also a step further. Since the problem was adding
interactivity to inline matplotlib plots, I wrapped the necessary bits in a
function like this:
def add_cursor(fig, ax):
plt.close()
vline = ax.axvline(1, color='k')
hline = ax.axhline(1, color='k')
def set_cursor(x, y):
vline.set_xdata((x, x))
hline.set_ydata((y, y))
display(fig)
interact(set_cursor, x=ax.get_xlim(), y=ax.get_ylim())
and then simply add a call to add_cursor whenever is needed. In this case
display() is called by interact(). I will probably write a couple of
similar functions for various "interactivity needs".
Thanks again,
Antonio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140729/604c9b5e/attachment.html>
More information about the IPython-dev
mailing list