threading issues with vpython

I am trying to combine matplotlib and vpython (the visual module) and
I am running into a threading issue (I think that is the issue). I am
basically trying to create a virtual demo for a feedback controls
course. I show an animation of a pendulum with different controls (P,
PD, PID, ...) and then after a few seconds of demo, the visual
animation loop calls a function that plots the step response of the
system with pylab. This all works great the first time, and after I
close the pylab window, the animation starts back up again as I think
it should. But I can't get additional plot windows to work correctly.
At first I just called show() at the end of the plot loop. When I
did that, the first time plotting worked correctly, the second time
did nothing and the third showed an empty plot (I manually closed the
plot window each time to resume the annimation thread). Later I added
a pylab.close('all') after pylab.show() as an attempt to clean up
after the window closing. Now the first plot is still good, but all
the rest don't seem to do anything.

Does anyone have any experience making vpython/visual play well with matplotlib?

I am using the TkAgg backend.

Thanks,

Ryan

Switching to the GTKAgg backend seems to fix this problem. Does that
make sense? Can this be made to work with the TkAgg backend or should
I just plan to use a different backend for this kind of thing?
(obviously that isn't a big deal if I just drop a matplotlibrc file in
the animation directory.)

Thanks,

Ryan

···

On 3/8/06, Ryan Krauss <ryanlists@...287...> wrote:

I am trying to combine matplotlib and vpython (the visual module) and
I am running into a threading issue (I think that is the issue). I am
basically trying to create a virtual demo for a feedback controls
course. I show an animation of a pendulum with different controls (P,
PD, PID, ...) and then after a few seconds of demo, the visual
animation loop calls a function that plots the step response of the
system with pylab. This all works great the first time, and after I
close the pylab window, the animation starts back up again as I think
it should. But I can't get additional plot windows to work correctly.
At first I just called show() at the end of the plot loop. When I
did that, the first time plotting worked correctly, the second time
did nothing and the third showed an empty plot (I manually closed the
plot window each time to resume the annimation thread). Later I added
a pylab.close('all') after pylab.show() as an attempt to clean up
after the window closing. Now the first plot is still good, but all
the rest don't seem to do anything.

Does anyone have any experience making vpython/visual play well with matplotlib?

I am using the TkAgg backend.

Thanks,

Ryan

Ryan, does it make any sense to send me your code offline?

In return, I'll send you something I have that uses Tkinter, vpython, and threading (but no MPL). We might not be able to crack each other's logic, but we both might learn something.

Hmm... I might have some stuff left over from when I was trying to use vpython and MPL for realtime plotting. IIRC, it worked but was slow.

BTW, I ended up using Pmw.Blt for reatime plotting. It works ok and is fast, but is a bit scary because development has been moribund (some recent signs of activity).

-Gary

Ryan Krauss wrote:

···

I am trying to combine matplotlib and vpython (the visual module) and
I am running into a threading issue (I think that is the issue). I am
basically trying to create a virtual demo for a feedback controls
course. I show an animation of a pendulum with different controls (P,
PD, PID, ...) and then after a few seconds of demo, the visual
animation loop calls a function that plots the step response of the
system with pylab. This all works great the first time, and after I
close the pylab window, the animation starts back up again as I think
it should. But I can't get additional plot windows to work correctly.
At first I just called show() at the end of the plot loop. When I
did that, the first time plotting worked correctly, the second time
did nothing and the third showed an empty plot (I manually closed the
plot window each time to resume the annimation thread). Later I added
a pylab.close('all') after pylab.show() as an attempt to clean up
after the window closing. Now the first plot is still good, but all
the rest don't seem to do anything.

Does anyone have any experience making vpython/visual play well with matplotlib?

I am using the TkAgg backend.

Thanks,

Ryan

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users