[IPython-User] Example/Tutorial of IPython + thread for matplotlib
Sat Jan 14 10:23:51 CST 2012
On Thu, Jan 12, 2012 at 2:20 PM, 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).
Thanks, Paul. Unfortunately this isn't quite what I wanted. I can see
that the plot is separate from the IPython interpreter.
What I want is one thread to do the calculation and another thread to
monitor the calculation (i.e., see how an array changes) and plot the
changes every ten seconds (or so). I'm looking for a simple example of
how to do this.
More information about the IPython-User