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 <dve...@lifewaveinc.com> 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@lists.sourceforge.net
> 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.


------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to