title: Record interactive plot
body: <p>The following code works fine to save an animation to file:</p>
  
  <pre><code>import numpy as np
  import matplotlib
  import matplotlib.pyplot as plt
  import matplotlib.animation as animation
  
  
  Writer = animation.writers['ffmpeg']
  writer = Writer(fps=15, bitrate=1800)
  
  fig, ax = plt.subplots()
  
  ims = []
  x = np.linspace(0, np.pi,200)
  for theta in np.linspace(0, np.pi, 50):
      plot = ax.plot(x, np.sin(x + theta))
      ims.append(plot)
  
  im_ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True)
  im_ani.save('im.mp4', writer=writer)
  </code></pre>
  
  <p>Now, I would like to view the animation interactively as the plots are generated, while still saving it to file. I therefore tried the following code:</p>
  
  <pre><code>import numpy as np
  import matplotlib
  import matplotlib.pyplot as plt
  import matplotlib.animation as animation
  
  Writer = animation.writers['ffmpeg']
  writer = Writer(fps=15, bitrate=1800)
  
  plt.ion()
  fig, ax = plt.subplots()
  
  ims = []
  x = np.linspace(0, np.pi, 200)
  for theta in np.linspace(0, np.pi, 50):
      ax.clear()
      plot = ax.plot(x, np.sin(x + theta))
      ims.append(plot)
      plt.draw()
      plt.pause(0.01)
  
  im_ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True)
  im_ani.save('im.mp4', writer=writer)
  </code></pre>
  
  <p>which lets me view the animation interactively, but the resulting video file contains only blank frames.
  Is is possible to view an animation interactively and save it to file at the same time? What is the issue with my code?</p>