just wanted preface huge thank whole community, it's i've learned of know!
anyway, i'm having issue matplotlib's animation module.
i've cut code down seems problem. code below works:
import numpy np import matplotlib.pyplot plt import matplotlib.animation animation ionfig = plt.figure(figsize=(18.0, 12.5)) ionplot = ionfig.add_subplot(111) ionscatter = [] plots = {} plots['pos'] = [ [[0,2,4, 0,2,4],[1,1,1, 1,1,1]] , [[5,6,8, 5,6,8],[1,4,3, 1,4,3]] ] ionplot.set_xlim(0,10) ionplot.set_ylim(0,10) particle in range(len(plots['pos'])): ionscatter.append(ionplot.scatter(plots['pos'][particle][0][0], plots['pos'][particle][1][0], s=6)) scatter in ionscatter: scatter.remove() def animate(i, ionscatter, plots): print particle in range(len(plots['pos'])): ionscatter[particle].set_offsets([plots['pos'][particle][0][i], plots['pos'][particle][1][i]]) return ionscatter ani = animation.funcanimation(ionfig, animate, fargs=[ionscatter, plots], frames=len(plots['pos'][0][0]), interval=0, blit=true, repeat=true) ionfig.show()
but i'd set interval non-zero number, slow down animation. however, when change second last line to:
ani = animation.funcanimation(ionfig, animate, fargs=[ionscatter, plots], frames=len(plots['pos'][0][0]), interval=100, blit=true, repeat=true)
the figure shows split second, , closes.
setting to
ani = animation.funcanimation(ionfig, animate, fargs=[ionscatter, plots], frames=len(plots['pos'][0][0]), interval=100, blit=true, repeat=true)
causes same error, ,
ani = animation.funcanimation(ionfig, animate, fargs=[ionscatter, plots], frames=len(plots['pos'][0][0]), interval=0, blit=false, repeat=true)
causes blank window appear , not disappear.
in these cases i've got callback printing out iteration number i. in first 2 cases twice, both 0's. in last case, cycle through, said window empty. case less interesting anyway interval 0.
so reason, having non-zero interval messes animation, ideas why be? i've had around couldn't seem find much.
don't imagine makes of difference i'm on ubuntu 14.
thanks bunch!
so i've found solution, although don't know why works.
it seems using plt.show() opposed ionfig.show() allows interval used. i'm assuming using ionfig.show() isn't enough doesn't tell animation start itself, line may needed if 1 wants do? not sure, if knows anymore let me know.
Comments
Post a Comment