use*_*508 6 python png matplotlib python-imaging-library
我正在尝试打开一系列的.png情节.我希望能够在屏幕上查看情节,然后得到提示,等待我"按下回车".在按下回车时,应显示下一个图.我已经看到了许多与此类似的问题(Matplotlib - 强制绘图显示然后返回主代码)但是当我这样做时,我必须手动点击绘图窗口右上角的X来关闭它并且仅然后代码继续.
我使用的是python 2.7.8
这是我的代码:
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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8284 次 |
| 最近记录: |