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

after use('Agg'), the animate does not work well #2552

Closed
zhangciwu opened this issue Oct 28, 2013 · 3 comments
Closed

after use('Agg'), the animate does not work well #2552

zhangciwu opened this issue Oct 28, 2013 · 3 comments

Comments

@zhangciwu
Copy link

matplotlib.animation.FuncAnimation(fig, func, frames=None, init_func=None, fargs=None, save_count=None, **kwargs)

after use('Agg')
the function above will trigger "func" function only once, and never all it twice.

scene: using animate to display lines one by one, and then save the picture.(works well without use Agg on windows.)
version:1.3.1

@zhangciwu
Copy link
Author

a small sample:

import matplotlib
#matplotlib.use('Agg')
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

def update_line(num, data, line):
    fig1.savefig('lines.png',format='png')
    line.set_data(data[...,:num])
    print 'run once'

    return line,

fig1 = plt.figure()

data = np.random.rand(2, 25)
l, = plt.plot([], [], 'r-')
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.xlabel('x')
plt.title('test')
line_ani = animation.FuncAnimation(fig1, update_line, 25, fargs=(data, l),
    interval=50, blit=False)

plt.show()

this works well, but when uncomment the second line, it doesn't work

@WeatherGod
Copy link
Member

The "Agg" backend is not a GUI backend. When you do a "plt.show()" for such
a backend, nothing will happen, regardless if it was an animation or not.
You can only save the animation.

@zhangciwu
Copy link
Author

Thanks.
I think I need to change the method to reach what I want.

@efiring efiring closed this as completed Oct 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants