Suitable for high speed plotting?

Jay Parlar wrote:

Our first run at it was using matplotlib with wx, but the update was
horrendous (roughly 2 fps).

hmm. MPL is pretty slow, but that's worse than it should be. Were you
using wxAgg or plain wx?

def Draw(self, DC):
        DC = wx.PaintDC(self)
        DC.SetBackground(wx.Brush("White"))
        DC.Clear()

        GC = wx.GraphicsContext.Create(DC)

GraphicsContext is pretty slow (though it shouldn't be on OS-X). Have
you tried a regular old DC?

I update self.points in the event handler, and it will always consist
of 500 (X,Y) tuples. So essentially, I'm trying to draw a 500 point
line 20 times per second.

That should be totally doable.

Is this the best way to do this? Anyone have any hints for going
faster, and using less CPU?

try a plain DC.

If you want fancier features, you could try wx.lib.floatcanvas. It uses
a plain old DC for drawing, and can easily do 20Hz for a 500 point line.
It also uses numpy which can be wonderful for this kind of thing.

For more info on FloatCanvas:

http://morticia.cs.dal.ca/FloatCanvas/

There are a bunch of additional demos in SVN (and the latest release).
Check out the MovingPlot.py demo.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

hmm. MPL is pretty slow, but that's worse than it should be. Were you
using wxAgg or plain wx?

We were using wxAgg. But even if we could speed up the MPL a bit, I
don't think it'll be fast enough.

Luckily, with all the hints everyone's thrown back at me so far, I've
got it running really nicely now! 20fps, three plots at the same time,
using about 15% of one of the CPUs on my MacBook. It's important that
the CPU usage remain really low, because the plotting is just the
beginning of the application. We'll be doing realtime analysis of the
data and lots and lots of FFTs.

> def Draw(self, DC):
> DC = wx.PaintDC(self)
> DC.SetBackground(wx.Brush("White"))
> DC.Clear()
>
> GC = wx.GraphicsContext.Create(DC)

GraphicsContext is pretty slow (though it shouldn't be on OS-X). Have
you tried a regular old DC?

I'm still using GraphicsContext. One of my original problems was the
way I was implementing my circular queue, so I was actually trying to
plot 2048*3 points every time, instead of 500*3.

We're doing all of our dev work on OS X, but it'll have to be on
Windows eventually. Does regular old DC have Translate() and Scale()
equivalents? I want the graph centered on (0,0), and that's easy to do
with a GC Translate() call. (Yes, I could just adjust my incoming
units to do the Translate manually, and I probably will, but it'd be
great if there were an easy way)

> I update self.points in the event handler, and it will always consist
> of 500 (X,Y) tuples. So essentially, I'm trying to draw a 500 point
> line 20 times per second.

That should be totally doable.

And it was :slight_smile:

If you want fancier features, you could try wx.lib.floatcanvas. It uses
a plain old DC for drawing, and can easily do 20Hz for a 500 point line.
It also uses numpy which can be wonderful for this kind of thing.

For more info on FloatCanvas:

http://morticia.cs.dal.ca/FloatCanvas/

There are a bunch of additional demos in SVN (and the latest release).
Check out the MovingPlot.py demo.

FloatCanvas looks cool. FYI, I *had* to install it from SVN. I first
tried downloading the .tgz release, and it downloaded an empty file. I
then tried downloading the .zip release, and the contents of the
"floatcanvas" directory were empty.

Thanks to everyone for all the help!

Jay P.

···

On 9/28/07, Chris.Barker@noaa.gov <Chris.Barker@noaa.gov> wrote:

Jay Parlar wrote:

We're doing all of our dev work on OS X, but it'll have to be on
Windows eventually. Does regular old DC have Translate() and Scale()
equivalents?

There is SetDeviceOrigin and SetUserScale.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

What's the difference between SetUserScale and SetLogicalScale? They
both seem to behave roughly the same.

Jay P.

···

On 9/28/07, Robin Dunn <robin@alldunn.com> wrote:

There is SetDeviceOrigin and SetUserScale.

Jay Parlar wrote:

···

On 9/28/07, Robin Dunn <robin@alldunn.com> wrote:

There is SetDeviceOrigin and SetUserScale.

What's the difference between SetUserScale and SetLogicalScale? They
both seem to behave roughly the same.

It looks like SetLogicalScale is intended for internal use only. I don't know what it is used for, or why it is separated from SetUserScale...

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!