title: Getting matplotlib animation to work
body: <p>Hi I'm having trouble in getting matplotlib animation to work
  The idea is to animate throughout a few lists and images.
  a[0] is basically time points/images to plot/imshow
  "timepoints[a[0].astype(np.int)][:i]/60" is simply the indexed "real time" to be in the x axis</p>
  
  <p>May anyone give me some hints?</p>
  
  <p>Appreciated </p>
  
  <pre><code>def draw_plot(resolution,timepoints,a,ts_g,ts_r,contrast):
  
      def animate(i):
  
          #~ ax.cla()
          #~ ax2.cla()
          #~ ax3.cla()
          #~ ax4.cla()
          print "ax"
          ax.errorbar(timepoints[a[0].astype(np.int)][:i]/60,list(a[1][0])[:i], yerr=list(a[4][0])[:i], fmt='-o',color='green')
          ax.errorbar(timepoints[a[0].astype(np.int)][:i]/60,list(a[1][1])[:i], yerr=list(a[4][1])[:i], fmt='-o',color='red')
          ax.axis([0,timepoints[a[0].astype(np.int)][-1]/60,np.min(np.concatenate((a[1][0],a[1][1])))*0.75,np.max(np.concatenate((a[1][0],a[1][1])))*1.3])
          ax.set_autoscale_on(False)
          print "ax2"
          ax2.plot(timepoints[a[0].astype(np.int)][:i]/60,list(a[2][0])[:i],color='green')
          ax2.plot(timepoints[a[0].astype(np.int)][:i]/60,list(a[2][1])[:i],color='red')
          ax2.axis([0,timepoints[a[0].astype(np.int)][-1]/60,np.min(np.concatenate((a[2][0],a[2][1])))*0.75,np.max(np.concatenate((a[2][0],a[2][1])))*1.3])
          ax2.set_autoscale_on(False)
  
          j = int(a[0][i]-1)
          r = ts_r[j]#.T
          g = ts_g[j]#.T
  
          max_ = contrast[3]
          min_ = contrast[2]  #~ 
          r[r&gt;max_]=max_
          r[r&lt;min_]=min_
          r -= min_
          r *= _16bit/(max_-min_)#r.max()
  
          max_ = contrast[1]
          min_ = contrast[0]
          g[g&gt;max_]=max_
          g[g&lt;min_]=min_
          g -= min_
          g *= _16bit/(max_-min_)#r.max()
          #~ 
          g_16 = g
  
          r = (r*ratio).astype(np.uint8)
          g = (g*ratio).astype(np.uint8)
          b = np.zeros(r.shape).astype(np.uint8)
          centered = np.dstack((r,g,b)).astype(np.uint8)
  
          #~ aa = np.dstack((np.zeros(ts[0].shape).T,ts[j].T,np.zeros(ts[0].shape)))
          print "ax3"
          ax3.imshow(centered)
          ax3.plot(list(a[5][0]/resolution)[:i],list(512-a[5][1]/resolution)[:i],color='blue')
          ax3.axis([0,512,512,0])
  
          print "ax4"
          ax4.imshow(centered)
          x = int (list(a[5][0]/resolution)[i])
          y = int (list(512-a[5][1]/resolution)[i])
          #~ ax4.axis([512,0,512,0])
          ax4.axis([x-10,x+10,y-10,y+10])
          ax4.get_xaxis().set_visible(False)
          ax4.get_yaxis().set_visible(False)
          print "ax5"
          ax5.imshow(g_16,cmap='gray')
          #~ x = int (list(a[5][0]/resolution)[i])
          #~ y = int (list(512-a[5][1]/resolution)[i])
          #~ ax4.axis([512,0,512,0])
          ax5.axis([x-10,x+10,y-10,y+10])
          ax5.get_xaxis().set_visible(False)
          ax5.get_yaxis().set_visible(False)
          plt.draw()
  
  
      fig = plt.figure()
  
  
      ax = plt.subplot2grid((2,5), (0,0),colspan=2)
      ax2 = plt.subplot2grid((2,5), (1,0),colspan=2)
      ax3 = plt.subplot2grid((2,5), (0, 2), colspan=2,rowspan=2)
      ax4 = plt.subplot2grid((2,5), (0,4))
      ax5 = plt.subplot2grid((2,5), (1, 4))
      line, = ax.plot([], [], lw=2)
      line2, = ax2.plot([], [], lw=2)
  
      ani = animation.FuncAnimation(fig, animate, frames= len(a[0]), interval=20000,repeat=False,blit=True)
      plt.show()
  </code></pre>