Matplotlib and then wait for the feed

I am trying to open a series of .png plots. I want to be able to view the plot on the screen, and then get an invitation so that I press the "Enter" button. If hit, enter the following schedule. I saw a lot of questions like this ( Matplotlib - display the strength graph, and then return to the main code ), but when I do this, I need to manually click X on the top right of the graph window to close it, and only then the code continues.

I am using python 2.7.8

Here is my 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()
+4
source share
1 answer

matplotlib plt.show(block=False), matplotlib.

+10

All Articles