title: Animated graph to Animated Gif (Python)
body: <p>I have made a simple n-body simulator and I plot/animate the movement with the following code:</p>
  
  <pre><code>for i in range(N):
      [...]
      x = [ Rbod[j][0], Rbod[j][0]]
      y = [ Rbod[j][1], Rbod[j][1]]
      #print(R1, V1, A1, F12)
      if i%10 == 0:
          print(i)
          pylab.ion()
          pylab.scatter( x, y, c=(j/nbodies,j/nbodies,j/nbodies) )
          pylab.axis([-400, 400, -400, 400])
          pylab.draw()
  </code></pre>
  
  <p>Now I would really like to save the animation as a gif. Is this possible? The internet vaguely said that it was but not on how to do it with <code>pylab</code>. </p>
  
  <p>Example of 4 body interaction:
  <img src="https://i.stack.imgur.com/e2oNO.png" alt="enter image description here"></p>