下面的代码,可以无阻碍地show 5个figure,相当于开启了ipython的interactive 模式
具体参见stackoverflow: in matplotlib, is there a way to pop up a figure asynchronously?
1 #!/usr/bin/python 2 import pylab as plb 3 import matplotlib.pyplot as plt 4 def show_figure():
5 fig1=plt.figure(1) 6 ax = fig1.add_subplot(1,1,1) 8 ax.plot([1,2,3],[4,5,6],'ro-') 11 plt.ion() # turns on interactive mode 12 plt.show() # now this should be non-blocking 13
for i in range(5):
show_figure()
14 print "doing something else now" 15 raw_input('Press Enter to continue...')