title: matplotlib plot and then wait for raw input
body: <p>I am trying to open a series of .png plots. I want to be able to view a plot on the screen and then get a prompt waiting for me to 'press enter'. On hitting enter, the next plot should be shown. I have seen many questions similar to this (<a href="https://stackoverflow.com/questions/17149646/matplotlib-force-plot-display-and-then-return-to-main-code">Matplotlib - Force plot display and then return to main code</a>) but when I do this I then have to manually click X on the top right-hand-side of the plot window to close it and only then does the code continue. </p>
  
  <p>I am using python 2.7.8</p>
  
  <p>Here is my code:</p>
  
  <pre><code>from PIL import Image
  import matplotlib.pyplot as plt
  import matplotlib.image as mpimg
  import string
  import sys
  import shutil
  
  fig=plt.figure()
  
  Viewingfile = sys.argv[1]
  
  
  for test_file in open(Viewingfile, "r").readlines(): 
  
      fig.set_tight_layout(True)
      plt.ion()
      image=mpimg.imread(test_file + ".ps.png")
      ax = fig.add_subplot(1, 1, 1)
      imgplot = plt.imshow(image)
      plt.show()
  
      print test_file
      a = raw_input('Next plot?\n')
      if a == "1":
          print "Do something..I've skipped these details"
      plt.clf()
  
  plt.close()
  </code></pre>