#!/usr/bin/python from pylab import * x,y = 0,0 xs = [x] ys = [y] fnames = [] import time tstart = time.time() figure() show(False) for i in xrange(50): fname = "walk{:03d}.png".format(i) print fname t = 2*pi*rand() x += sin(t) y += cos(t) xs.append(x) ys.append(y) cla() plot(xs,ys) draw() savefig(fname) fnames.append(fname) print time.time()-tstart import subprocess, os print "merging animation" subprocess.check_call(["convert"] + fnames + ["walk.gif"]) print "deleting temp. files" for fname in fnames: os.remove(fname)