title: Animate lines every 2 seconds, Python
body: <p>I'm programming a chart that puts a line on the numbers 0, 10, 20(form the array) etc, until the maximum of the array. this works but the lines pop up at the same time, but i want them to pop up 1 sec after each other, starting at 0, a second later on 10, a sec later on 20 etc.</p>
  <p>I did some research and i know i need to do do it with the FuncAnimation from matplotlib. and a function over what needs to be popping up. but i can't get it to work.</p>
  <p>i would really love your help!</p>
  <p>here is some of my code</p>
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.colors as colors
  import gc
  from matplotlib.animation import FuncAnimation
  
  #reading my files
  #putting data in array called array
  
  #start plotting
  array = array - np.nanmin(array)
  
      fig, ax = plt.subplots()
      fig.set_size_inches((fileObject.numberOfColumnsInArray + 1) / 2 + 1, (fileObject.numberOfRowsInArray + 1) / 2)
      
      X_Major_ticks = np.arange(1, fileObject.numberOfColumnsInArray + 1)
      X_Minor_ticks = np.arange(1.5, fileObject.numberOfColumnsInArray)
      Y_Major_ticks = np.arange(1, fileObject.numberOfRowsInArray + 1)
      Y_Minor_ticks = np.arange(1.5, fileObject.numberOfRowsInArray)
      ax.set_xticks(X_Major_ticks)
      ax.set_xticks(X_Minor_ticks, minor=True)
      ax.set_yticks(Y_Major_ticks)
      ax.set_yticks(Y_Minor_ticks, minor=True)
  
      ax.grid(which='minor', alpha=1, color='black', linewidth=1)
      ax.grid(which='major', alpha=0, color='black', linewidth=0.6)
      
      ax.set_xlim(0.5, fileObject.numberOfColumnsInArray + .5)
      ax.set_ylim(0.5, fileObject.numberOfRowsInArray + .5)
      
      pos = plt.imshow(array, extent=[.5, fileObject.numberOfColumnsInArray + .5, fileObject.numberOfRowsInArray + .5, .5], cmap=reverse_colourmap(new_cmap), alpha=1)
      plt.clim(0,60)
      plt.grid(which='both', linestyle='--')    
  
  #        for i in range(fileObject.numberOfColumnsInArray):
  #            for j in range(fileObject.numberOfRowsInArray):
  #                if ~np.isnan(array[j, i]):
  #                    ax.text(i+1, j+1, int(array[j, i]), ha='center', va='center')
  
      for i in range(fileObject.numberOfColumnsInArray-1):
          for j in range(fileObject.numberOfRowsInArray):
              if abs(array[j, i] - array[j, i+1]) &gt;= blockCutOff:
                  ax.plot([i+1.5,i+1.5], [j+.5,j+1.5], linewidth=4.5,linestyle=':',color='#FF0000') 
                         
      for i in range(fileObject.numberOfColumnsInArray):
          for j in range(fileObject.numberOfRowsInArray-1):
              if abs(array[j, i] - array[j+1, i]) &gt;= blockCutOff:
                  ax.plot([i+.5,i+1.5], [j+1.5,j+1.5], linewidth=4.5, linestyle=':',color='#FF0000')
                       
   ##this part makes the lines on 0 10 20 etc. i want to put tose liens apart every 1 or 2 sec.!!!
   # i tried to start a function here but without results.
   #def animate(a):
      for i in range(fileObject.numberOfColumnsInArray):
          for j in range(fileObject.numberOfRowsInArray-1):
              while array[j, i] in range(int(np.nanmin(array)),int(np.nanmax(array)), Wavelinetime):
                  ax.plot([i+.5,i+1.5], [j+1.5,j+1.5], linewidth=3, linestyle='-',color='#000000')
                  break
      
      #with this i want to animate and call on the function called animate
      #ani = FuncAnimation(fig, animate, interval=3000)     
      ax.set_title(deflectionTableFile.rsplit ('\\')[-1].rsplit ('_')[0] + ': ' + deflectionTableFile.rsplit ('\\')[-1].rsplit ('_')[5] + ' wave ' + str(iWaveLabel))                  
      plt.gca().invert_yaxis()    
      plt.gca().set_aspect('equal', adjustable='box')
      
      cbar_ax = fig.add_axes([.85, 0.15, 0.05, 0.7])
      cbar = fig.colorbar(pos, cax=cbar_ax, extend='max', ticks=range(0,61,5))
      cbar.minorticks_on()
      cbar.ax.set_title('ms')
  </code></pre>