On Mon, Dec 29, 2008 at 1:13 AM, davev <dveach@...> wrote:
>
> After searching through the forums and trying many different things I have
> been unable to get animation working correctly using matplotlib in my python
> application. I'm hoping one of the experts here can take a quick look at my
> code and tell me what I am doing incorrectly.
I'll be happy to take a look at this -- I did a quick read through of
the code, and did not see an obvious error, so please create a
complete, free-standing example which uses model data, eg a sine wave
of varying amplitude or frequency over time, and I'll try and take a
look tonight on a machine which has wxpython installed. I
JDH

Will do (done actually). Here is the list of files:
http://www.nabble.com/file/p21208385/MyFrame.py MyFrame.py
http://www.nabble.com/file/p21208385/HeartPanel.py HeartPanel.py
http://www.nabble.com/file/p21208385/app.py app.py
http://www.nabble.com/file/p21208385/anim.wxg anim.wxg
I've included the wxGlade file just to be complete. Please let me know if
you see anything that is obviously wrong here. It's not much different from
some of the examples I've looked at but doesn't produce similar results.
dave
John Hunter-4 wrote:
>
> On Mon, Dec 29, 2008 at 1:13 AM, davev wrote:
>>
>> After searching through the forums and trying many different things I
>> have
>> been unable to get animation working correctly using matplotlib in my
>> python
>> application. I'm hoping one of the experts here can take a quick look at
>> my
>> code and tell me what I am doing incorrectly.
>
> I'll be happy to take a look at this -- I did a quick read through of
> the code, and did not see an obvious error, so please create a
> complete, free-standing example which uses model data, eg a sine wave
> of varying amplitude or frequency over time, and I'll try and take a
> look tonight on a machine which has wxpython installed. I
>
> JDH
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
--
View this message in context: http://www.nabble.com/python-and-matplotlib-animation-tp21185506p21208385.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

On Mon, Dec 29, 2008 at 2:04 PM, davev <dveach@...> wrote:
> Will do (done actually). Here is the list of files: MyFrame.py HeartPanel.py
> app.py anim.wxg I've included the wxGlade file just to be complete. Please
> let me know if you see anything that is obviously wrong here. It's not much
> different from some of the examples I've looked at but doesn't produce
> similar results. dave
The problem was that you did not call "draw" in your plot init method
before saving the background region. Unless you are in interactive
mode in pylab, you must manually force a figure draw with a call to
figure.canvas.draw. Eg, the method should look like::
def init_plot(self):
'''
Method to initialize the plot that is used to animate the display.
'''
self.figure.subplots_adjust(left=0, top=1, right=1, bottom=0)
self.axes = self.figure.add_subplot(111)
self.axes.set_axis_bgcolor('black')
self.figure.canvas.draw()
if self.bgnd == None:
self.bgnd = self.canvas.copy_from_bbox(self.axes.bbox)
self.x_data = num.arange(0, 2*num.pi, 0.01)
self.line = self.axes.plot(self.x_data, \
num.sin(self.x_data), \
color='green', \
figure=self.figure, \
lw=2, \
animated=True)
self.axes.hold(False)
I was able to run your example, and with these changes it works as expected.
JDH

Thank you John, that made the difference. I had read that you needed to call
the draw function for the canvas first but it wasn't clear from the
examples. Now that you have given me the correct place to make the call,
things are working as expected.
If we wanted to, this small project could easily be turned into an
additional example for the animation example code so that others could
potentially benefit from it as well. If you think that is a good idea, let
me know and I'll look at making it happen. At the very least, the final
version of the files could be posted so that others could easily
view/download the files as example code. I would include the wxGlade file so
that there would also be an example of that available as well.
Thanks again for the help.
dave
John Hunter-4 wrote:
>
> On Mon, Dec 29, 2008 at 2:04 PM, davev <dveach@...> wrote:
>> Will do (done actually). Here is the list of files: MyFrame.py
>> HeartPanel.py
>> app.py anim.wxg I've included the wxGlade file just to be complete.
>> Please
>> let me know if you see anything that is obviously wrong here. It's not
>> much
>> different from some of the examples I've looked at but doesn't produce
>> similar results. dave
>
> The problem was that you did not call "draw" in your plot init method
> before saving the background region. Unless you are in interactive
> mode in pylab, you must manually force a figure draw with a call to
> figure.canvas.draw. Eg, the method should look like::
>
> def init_plot(self):
> '''
> Method to initialize the plot that is used to animate the display.
> '''
> self.figure.subplots_adjust(left=0, top=1, right=1, bottom=0)
> self.axes = self.figure.add_subplot(111)
> self.axes.set_axis_bgcolor('black')
> self.figure.canvas.draw()
> if self.bgnd == None:
> self.bgnd = self.canvas.copy_from_bbox(self.axes.bbox)
>
> self.x_data = num.arange(0, 2*num.pi, 0.01)
> self.line = self.axes.plot(self.x_data, \
> num.sin(self.x_data), \
> color='green', \
> figure=self.figure, \
> lw=2, \
> animated=True)
> self.axes.hold(False)
>
>
> I was able to run your example, and with these changes it works as
> expected.
>
> JDH
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
--
View this message in context: http://www.nabble.com/python-and-matplotlib-animation-tp21185506p21222019.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

On Tue, Dec 30, 2008 at 1:31 PM, davev <dveach@...> wrote:
>
> Thank you John, that made the difference. I had read that you needed to call
> the draw function for the canvas first but it wasn't clear from the
> examples. Now that you have given me the correct place to make the call,
> things are working as expected.
>
> If we wanted to, this small project could easily be turned into an
> additional example for the animation example code so that others could
> potentially benefit from it as well. If you think that is a good idea, let
> me know and I'll look at making it happen. At the very least, the final
> version of the files could be posted so that others could easily
> view/download the files as example code. I would include the wxGlade file so
> that there would also be an example of that available as well.
Sure, that sounds great. I think the example with the start and stop
buttons would be nice, as would the wxglade part. I can add them to
the animations examples dir.
JDH

Please feel free to do so. If you need anything from me, I will be glad to
provide it.
dave
John Hunter-4 wrote:
>
> On Tue, Dec 30, 2008 at 1:31 PM, davev <dveach@...> wrote:
>>
>> Thank you John, that made the difference. I had read that you needed to
>> call
>> the draw function for the canvas first but it wasn't clear from the
>> examples. Now that you have given me the correct place to make the call,
>> things are working as expected.
>>
>> If we wanted to, this small project could easily be turned into an
>> additional example for the animation example code so that others could
>> potentially benefit from it as well. If you think that is a good idea,
>> let
>> me know and I'll look at making it happen. At the very least, the final
>> version of the files could be posted so that others could easily
>> view/download the files as example code. I would include the wxGlade file
>> so
>> that there would also be an example of that available as well.
>
> Sure, that sounds great. I think the example with the start and stop
> buttons would be nice, as would the wxglade part. I can add them to
> the animations examples dir.
>
> JDH
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
--
View this message in context: http://www.nabble.com/python-and-matplotlib-animation-tp21185506p21226091.html
Sent from the matplotlib - users mailing list archive at Nabble.com.