title: Defining multiple plots to be animated with a for loop in matplotlib
body: <p><a href="http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/" rel="noreferrer">Thanks to Jake Vanderplas</a>, I know how to start to code an animated plot with <a href="http://matplotlib.org/" rel="noreferrer"><code>matplotlib</code></a>. Here is a sample code:</p>
  
  <pre class="lang-python prettyprint-override"><code>from matplotlib import pyplot as plt
  from matplotlib import animation
  
  fig = plt.figure()
  
  ax = plt.axes(xlim=(0, 2), ylim=(0, 100))
  
  line, = plt.plot([], [])
  
  def init():
      line.set_data([], [])
      return line,
  
  def animate(i):
      line.set_data([0, 2], [0,i])
      return line,
  
  anim = animation.FuncAnimation(fig, animate, init_func=init,
                                 frames=100, interval=20, blit=True)
  
  plt.show()
  </code></pre>
  
  <p>Suppose now I'd like to plot tons of functions (say four here), defined with the help of a loop. I did some voodoo programming, trying to understand how to mimic the comma following line and here is what I got (needless to say that it does not work: <code>AttributeError: 'tuple' object has no attribute 'axes'</code>).</p>
  
  <pre class="lang-python prettyprint-override"><code>from matplotlib import pyplot as plt
  from matplotlib import animation
  
  fig = plt.figure()
  
  ax = plt.axes(xlim=(0, 2), ylim=(0, 100))
  
  line = []
  N = 4
  
  for j in range(N):
      temp, = plt.plot([], [])
      line.append(temp)
  
  line = tuple(line)
  
  def init():
      for j in range(N):
          line[j].set_data([], [])
      return line,
  
  def animate(i):
      for j in range(N):
          line[j].set_data([0, 2], [10 * j,i])
      return line,
  
  anim = animation.FuncAnimation(fig, animate, init_func=init,
                                 frames=100, interval=20, blit=True)
  
  plt.show()
  </code></pre>
  
  <p><strong>Some my question is:</strong> how can I make it work? Bonus (probably linked): what is the difference between <code>line, = plt.plot([], [])</code> and <code>line = plt.plot([], [])</code>?</p>
  
  <p>Thanks</p>