title: How to save the last image of a matplotlib animation?
body: <p>I would like to know how to save the last image of a <code>FuncAnimation</code> in Python 3. Here's some code:</p>
  
  <pre><code>import matplotlib.animation
  from mpl_toolkits.mplot3d import Axes3D
  
  ani = matplotlib.animation.FuncAnimation(fig, _update_2d_graph, frames=9, interval=600, repeat_delay=5000, blit=False)
  ani.save(output_dir, writer="imagemagick")
  </code></pre>
  
  <p>where <code>_update_2d_graph</code> is a function providing different offsets of points depending on the frame number:</p>
  
  <pre><code>def _update_2d_graph(num):
      x_updated = np.hstack((pos_gt.x[:num].tolist(),pos_pred.x[:num].tolist()))
      y_updated = np.hstack((pos_gt.y[:num].tolist(),pos_pred.y[:num].tolist()))
  
      paths_gt = []
      paths_ped = []
  
      for i in range(num):
          marker_gt = mmarkers.MarkerStyle('o')
          marker_ped = mmarkers.MarkerStyle('x')
          path_gt = marker_gt.get_path().transformed(marker_gt.get_transform())
          path_ped = marker_ped.get_path().transformed(marker_ped.get_transform())
          paths_gt.append(path_gt)
          paths_ped.append(path_ped)
  
      graph._paths = np.concatenate([paths_gt, paths_ped])
      graph.set_facecolors(np.concatenate([colors[:num], colors[:num]]))
      graph.set_edgecolors(np.concatenate([colors[:num], colors[:num]]))
      graph.set_offsets(np.hstack((y_updated[:, np.newaxis], x_updated[:, np.newaxis])))
  </code></pre>
  
  <p>Instead of saving the entire animation (e.g. as .gif file), I want to save a .png of the last time step of the animation. 
  <strong>Is it possible to access the last frame within the animation object?</strong> </p>
  
  <p>I don't want to call <code>_update_2d_graph(9)</code> since this call has already been executed by the animation object nor do I want to re-iterate over the entire 9 frames through another <code>FuncAnimation</code> call.</p>