moving line

I’m creating a simple little sound file editor, which includes the ability to play a sound file as a vertical line (a “cursor”) moves across the plot of the waveform in sync with the sound. So the trick is, how to create this moving line. First I tried FuncAnimation, but I had problems with the synchronization with the sound. I’m guessing that the animation capabilities of matplotlib weren’t really designed to be synchronized with outside activities. So then I tried using QTimer’s and modifying the Line2D instance that is the vertical bar. This didn’t work unless I called draw() on the figure canvas every time I modified the Line2D, which caused slowdown (probably because my audio data consists of 1000’s of points).

So is there a way to animate a vertical line moving across the plot with good control over exact timing, in the presence of other plots with thousands of points?

Mike

Hi Mike,

Have you tried blitting? That prevents the draw from redrawing everything on the plot, allowing it to only redraw the single line that’s moving, which should help any issues with speed. See some of the examples with FuncAnimation and also a Q&A using the draw method here, which might work more smoothly with QTimer.

Ray

···

On Sat, Apr 19, 2014 at 12:56 AM, Michael Mossey <michaelmossey@…287…> wrote:

I’m creating a simple little sound file editor, which includes the ability to play a sound file as a vertical line (a “cursor”) moves across the plot of the waveform in sync with the sound. So the trick is, how to create this moving line. First I tried FuncAnimation, but I had problems with the synchronization with the sound. I’m guessing that the animation capabilities of matplotlib weren’t really designed to be synchronized with outside activities. So then I tried using QTimer’s and modifying the Line2D instance that is the vertical bar. This didn’t work unless I called draw() on the figure canvas every time I modified the Line2D, which caused slowdown (probably because my audio data consists of 1000’s of points).

So is there a way to animate a vertical line moving across the plot with good control over exact timing, in the presence of other plots with thousands of points?

Mike


Learn Graph Databases - Download FREE O’Reilly Book

“Graph Databases” is the definitive new guide to graph databases and their

applications. Written by three acclaimed leaders in the field,

this first edition is now available. Download your free book today!

http://p.sf.net/sfu/NeoTech


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks, I’ll check it out. Note that I did get FuncAnimation to work
perfectly well except I have little control over the timing so I had
a hard time synchronizing it with the sound. The FuncAnimation
example I looked at wasn’t very helpful if the question is how to
blit or other details, because that’s all going on behind the
scenes. I will study the Stack Overflow Q&A and see if there is
something I can directly use.
Mike

···

On 4/19/2014 3:51 PM, Raymond Smith
wrote:

Hi Mike,

    Have you tried blitting? That prevents the draw from redrawing

everything on the plot, allowing it to only redraw the single
line that’s moving, which should help any issues with speed. See
some of the examples
with FuncAnimation and also a Q&A using the draw method here ,
which might work more smoothly with QTimer.

    Ray

Hi Mike,

I have the same problem and I am interested how dou you solve it.

Regards

Enzo

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/moving-line-tp43249p43686.html
Sent from the matplotlib - users mailing list archive at Nabble.com.