I'm plotting 2 graphs in the same figure inside a 'for' loop. The problem is that, in order to keep the loop running I have to manually close the figure using the mouse. This is difficult as the loop is over 300 steps long. I'm looking for a simpler solution, like clicking the number 1 to close the current figure and view next. I tried with the following code, and it is not working. I believe that the succeeding line is only read after the existing graph is closed. How to fix this?
P.S : Also, using raw_input()
for the keypress is not a good way, as I have to additionally hit the 'Enter'. So suggest an alternate method where I can close the graphs by continuously pressing '1' .
for roww in range (0,height) :
com = 0
isignal = matrix[roww]
fft_ith = np.fft.fft(isignal)
fft_abs_ith = np.abs(fft_ith)
c_fft = fft_abs_ith[:len(fft_abs_ith)//2]
c_fft[zi] = 0
plt.subplot(2,1,1)
plt.plot(time,isignal,marker='.')
plt.xlim(0,time[len(time)-1])
plt.title("Individual oscilations and FFT of each cell \n cell ="+str(roww))
plt.subplot(2,1,2)
plt.plot(c_freqq,c_fft,marker = ".")
plt.show()
comnd = raw_input()
if comnd == 1
plt.close()