title: How to toggle visibility of matplotlib figures?
body: <p>Is there a way that I can make a matplotlib figure disappear and reappear in response to some event? (i.e. a keypress)</p>
  
  <p>I've tried using <code>fig.set_visible(False)</code> but that doesn't seem to do anything for me.</p>
  
  <p>Simple example of code:</p>
  
  <pre><code>import matplotlib
  import matplotlib.pyplot as plt
  
  fig=matplotlib.pyplot.figure(figsize=(10, 10))
  
  # Some other code will go here
  
  def toggle_plot():
    # This function is called by a keypress to hide/show the figure
    fig.set_visible(not fig.get_visible()) # This doesn't work for me
  
  plt.show()
  </code></pre>
  
  <p>The reason I'm trying to do this is because I have a bunch of plots/animations running on the figure that show the output of a running simulation, but displaying them all the time slows down my computer a lot. 
  Any ideas?</p>