Multiple plots, interactivity, wx etc

Hi,

I have couple of applications in which I have to generate multiple plots
interactively using the wx backend and wanted to know the best
approach to take for this. I did search the list for previous

discussions on this subject, but the approach to take is still
unfortunately not 100% clear to me.

The first use case is that I want to be able to “show” plots as soon
as they are ready. The script sits in a loop pulling out data from

different sources, does some transformations and then plots it. Now I
understand the recommended way to call show() when all the plots are
ready. But since there are many many plots and it take some time to
generate one, I would like to show the plot window as soon as it is

ready and furthermore I want all the plot windows to be alive so that
I can go back and forth through them. I tried using pylab.ion(), but
then after the script exits, all the windows disappear along with it.

The other use case is more like ipython. I have a program to connect
to a database and the user interacts with it using queries. I would
like to add visualization support to it The user should be able to plot
the data as needed and keep all the plot windows alive.

How can I do this using mpl and wx backend? Do you recommend using
threading or forking plots as separate processes?

Thanks,
Suchindra

bump …

···

On Thu, Jul 31, 2008 at 11:02 AM, signal seeker <seekersignal@…287…> wrote:

Hi,

I have couple of applications in which I have to generate multiple plots
interactively using the wx backend and wanted to know the best
approach to take for this. I did search the list for previous

discussions on this subject, but the approach to take is still
unfortunately not 100% clear to me.

The first use case is that I want to be able to “show” plots as soon
as they are ready. The script sits in a loop pulling out data from

different sources, does some transformations and then plots it. Now I
understand the recommended way to call show() when all the plots are
ready. But since there are many many plots and it take some time to
generate one, I would like to show the plot window as soon as it is

ready and furthermore I want all the plot windows to be alive so that
I can go back and forth through them. I tried using pylab.ion(), but
then after the script exits, all the windows disappear along with it.

The other use case is more like ipython. I have a program to connect
to a database and the user interacts with it using queries. I would
like to add visualization support to it The user should be able to plot
the data as needed and keep all the plot windows alive.

How can I do this using mpl and wx backend? Do you recommend using
threading or forking plots as separate processes?

Thanks,
Suchindra

Hello,

How can I do this using mpl and wx backend? Do you recommend using
threading or forking plots as separate processes ?

None of the above is necessary.

Add this to imports:
import matplotlib
matplotlib.use('WXAgg')

import matplotlib.cm as cm
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure
from pylab import *

Just instanciate some wx.panel with inside

self.sizer = wx.BoxSizer(wx.VERTICAL)
fig = Figure()
self.figure = FigureCanvasWxAgg(self.widget, -1, fig)
self.sizer.Add(self.figure, 1, wx.EXPAND)

x1 = array(var1['data'])
y1 = array(var1['data'])
        
axes = fig.add_subplot(111)#211)
axes.yaxis.tick_left()
axes.plot(x1,y1,alpha=1)
           
And should be OK.
Personnaly I use wx.aui to manage multpile wx.panel inside an App, but it
depends what you want to do with your app.

Laurent