Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-subplot animation problem #1203

Closed
gfunch opened this issue Sep 4, 2012 · 2 comments
Closed

multi-subplot animation problem #1203

gfunch opened this issue Sep 4, 2012 · 2 comments

Comments

@gfunch
Copy link

gfunch commented Sep 4, 2012

I am trying to create a multi-subplot animation which is loosely based
on the animation example code, subplots.py, at
http://matplotlib.sourceforge.net/examples/animation/subplots.html

A simplified version of the full code is shown at this gist:
https://gist.github.com/3613113

I am having problems getting the code to function properly. If I run
it as is, the figure appears, but no animation is done. Apparently
the setup code is called, but the code to change the frames is not.
If I comment out the call to the setup code, the method to update
the frame is called once, and that is it.

@nithyanandan
Copy link

Did you try setting blit=False ? I had a problem where one of the subplots was static and the other was animating. Setting blit=False solved my problem.

@tacaswell
Copy link
Member

The problem is related to #1656 . All of the timers and such for the animation are wrapped up in the FuncAnimation object. As your gist file is, you do not keep a ref to ani around so it gets garbage collected after __init__ opens.

Changing your __init__ to

class DataAnimator(object):
    def __init__(self):
        ...
        self.ani = animation.FuncAnimation(self.fig, self._update_frame, init_func=self._setup)

makes your gist behaves correctly.

Given how often this comes up, there should be something added to the documentation. Closing this in favor of #1656 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants