HOW TO: have multiple plot windows open at the same time?

Hi Everyone,

I just started to use pylab, and there are two issues I can't figure
out a way to get around.

1. show() does not return until I close the plot window. This makes it
impossible to show multiple plots at the same time. How can I show
multiple plots?

2. How can I get a handle or object reference to the plot window so
that I can manipulate it specifically?

I found some references to the API. The API seems quite different from
the plot interface and is considerably low-level. So am just wondering
if using the API is the only way to do these things. It seems to me
that if plot(...) can return an object reference to the chart winodw,
all these can easily be solved.

Thanks,
Geoffrey

Hi Everyone,

I just started to use pylab, and there are two issues I can't figure
out a way to get around.

1. show() does not return until I close the plot window. This makes it
impossible to show multiple plots at the same time. How can I show
multiple plots?

2. How can I get a handle or object reference to the plot window so
that I can manipulate it specifically?

Is this what you're after?

import pylab as p

f0 = p.figure()
f1 = p.figure()
ax0 = f0.add_subplot(111)
ax0.plot(data)
ax1 = f1.add_subplot(111)
ax1.plot(otherdata)

···

On 21/08/07, Geoffrey Zhu <zyzhu2000@...287...> wrote:

I found some references to the API. The API seems quite different from
the plot interface and is considerably low-level. So am just wondering
if using the API is the only way to do these things. It seems to me
that if plot(...) can return an object reference to the chart winodw,
all these can easily be solved.

Thanks,
Geoffrey

--
AJC McMorland, PhD Student
Physiology, University of Auckland

Hi Everyone,

I just started to use pylab, and there are two issues I can't figure
out a way to get around.

1. show() does not return until I close the plot window. This makes it
impossible to show multiple plots at the same time. How can I show
multiple plots?

The way pylab displays things requires you to have an active GUI main
loop running in order for the plots to show up and be active. One
way around it is to use the ipython -pylab mode. This starts the GUI
in a thread and does some magic behind the scenes so that you can keep
typing at the prompt while a figure is showing.

If you're trying to show multiple plots from a program and you don't
want to block, I wrote a pylab plot server called ez_plot that you may
find of use. You can get it from pypi or via "easy_install ez_plot".
Basically when you call ez_plot.Plotter().<pylab command> it packs
the method name and all its arguments up and sends it to the plot
server to plot. If the server isn't running it starts one up. The
plot server is just a separate process that sits around waiting for
people to send it plotting commands. But since it's a separate
process it can sit in the GUI loop without affecting the control flow
of your code.

I use it mostly for debugging. You can do something like this in the
header of your python file to switch back and forth:

if debug:
    import ez_plot
    Plot = ez_plot.Plotter()
else:
    from matplotlib import pylab as Plot

2. How can I get a handle or object reference to the plot window so
that I can manipulate it specifically?

I found some references to the API. The API seems quite different from
the plot interface and is considerably low-level. So am just wondering
if using the API is the only way to do these things. It seems to me
that if plot(...) can return an object reference to the chart winodw,
all these can easily be solved.

Most commands do return an object that you can manipulate. Again
ipython is a big help here. Just try x = pylab.plot(somethign), and
then you can use ipython's tab completion and such to quickly see what
sort of things you can do with the x you got back.

--bb

···

On 8/21/07, Geoffrey Zhu <zyzhu2000@...287...> wrote: