Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixes to funcanimation #4800

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

Merged
merged 4 commits into from
Jul 31, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add init function to anim decay example
Ensures that the plot is cleared before restarting the animation
  • Loading branch information
jenshnielsen committed Jul 27, 2015
commit aa04769b771b692e7dab05e810e5e051a1404aa8
12 changes: 9 additions & 3 deletions examples/animation/animate_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ def data_gen(t=0):
t += 0.1
yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)

def init():
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 10)
del xdata[:]
del ydata[:]
line.set_data(xdata,ydata)
return line,

fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2)
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 5)
ax.grid()
xdata, ydata = [], []

Expand All @@ -33,5 +39,5 @@ def run(data):
return line,

ani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,
repeat=False)
repeat=False, init_func=init)
plt.show()