[IPython-User] Example/Tutorial of IPython + thread for matplotlib
Thu Jan 12 15:42:34 CST 2012
On Thu, Jan 12, 2012 at 13:20, Paul Ivanov <firstname.lastname@example.org> wrote:
> Jeremy Conlin, on 2012-01-12 11:52, wrote:
> > I need to monitor the progress of a calculation and would like to do
> > that by continually updating a matplotlib plot while the rest of the
> > calculation continues. I know this could be done using a separate
> > thread, but I'm not sure how to implement it.
> > Does anyone have—or can point me to—an example or tutorial that can
> > show me how to do this?
> Hi Jeremy,
> you can get the functionality you want by simply starting up
> IPython with --pylab (I believe that the most recent version of
> IPython has a %pylab magic which allows you to do this after
> ipython's been started).
> IPython takes care of this separate thread for you.
You can check
> that it works by doing something as simple as
> In : plt.plot([3,1,4]);
> In : plt.show();
> And then see that you can manipulate the plot with your mouse,
> but still type in new commands at the ipython prompt and have
> them execute. (Without threading, you'd be blocked after the call
> to plt.show() until you closed the figure that pops up).
This isn't quite accurate - IPython no longer runs the eventloop in a
separate thread as of 0.11. Instead, IPython integrates the eventloop and
the inputhook directly.
See the output of `threading.enumerate()` for confirmation - there are only
two threads, main and the background history-save.
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
> IPython-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User