[Matplotlib-users] Graph animation performance

2013-08-25 Thread Peter Zimmer
Hello,
I want a real-time animation. There is no loop in the animation because
the data comes from the real world (AD data). I wrote this class:


class Eigendiagramm(object):
def __init__(self,daten):
self.DiagrammBreite = gtk.Adjustment(100,20,1,1,10,10)
self.DiagrammBreiteWidget = gtk.VScale(self.DiagrammBreite)
self.DiagrammBreiteWidget.connect("value_changed",
self.updateBreite, None)
   
self.data = daten
   
self.fig = Figure()

self.fig.set_animated(True)
self.graph = self.fig.add_subplot(111)
self.line, = self.graph.plot(self.data.get_ekg_data(),)
self.graph.axis([0, self.DiagrammBreite.get_value(), 0, 4096])
self.canvas = FigureCanvas(self.fig)

   
self.DiagrammBreite = gtk.Adjustment(100,20,1,1,10,10)
self.DiagrammBreiteWidget = gtk.VScale(self.DiagrammBreite)
self.DiagrammBreiteWidget.connect("value_changed",
self.updateBreite, None)

def updateGraph(self,data):
datacut = data[1 - self.DiagrammBreite.get_value():1]
self.line.set_ydata(datacut)
self.line.set_xdata(numpy.arange(0, datacut.size, 1))
self.fig.canvas.draw()

def updateBreite(self,widget, data = None):
self.graph.axis([0, self.DiagrammBreite.get_value(), 0, 4096])   

It works but it is very slow. (About 160mS for updateGraph when I have
two graphs) Is there any possibility to improve the performance?  I
embedded the figure in GTK.

I looked to animation examples but every example there is a loop. So I
don't know how to use this class for my problem.

Peter

--
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Graph animation performance

2013-08-25 Thread Skip Montanaro
> def updateGraph(self,data):
> datacut = data[1 - self.DiagrammBreite.get_value():1]
> self.line.set_ydata(datacut)
> self.line.set_xdata(numpy.arange(0, datacut.size, 1))
> self.fig.canvas.draw()

If nothing else, it appears that the plot's x data are constant.  Have
you tried just setting it once when you create self.line?

Skip

--
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Explicitly clearing Matplotlib/Pylab figure buffers

2013-08-25 Thread Goyo
2013/8/23 Kari Aliranta :
> 23.08.2013 20:57, Eric Firing kirjoitti:

> Thank you. I'd like to stick to pure OO, but I'm using some
> third party open source code that uses pylab extensively for
> rather large and interactive (as in "includes scrollbars,
> buttons and several types of events") figures. The code
> works nicely in itself, and has an option to return the
> figure object without actually showing the plot.
>
> I was hoping to take the returned figure as an object and
> reset the related state environment information, effectively
> "smuggling" the created figure out of the state environment.
> If there is a simple way to do this in Matplotlib, that
> would be quite useful.

Does pyplot.close(fig) not do what you need?

Goyo

--
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users