Currently using Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 11:57:41) on Windows (64 bits).
I want a procedure that I am writing to generate two different plots. One plot will have three separate graphs and then I want a separate window that shows a histogram.
plt.subplot(311)
plt.plot(z)
plt.xlabel('Time(s)', fontsize=14)
plt.ylabel('Amplitude(v)', fontsize=8)
fig.subplots_adjust(hspace=.5)
plt.figure
plt.subplot(312)
plt.plot(timey[0:(len(freq))//2],y)
plt.xlabel('Frequency(Hz)', fontsize=14)
plt.ylabel('Amplitude(V)', fontsize=8)
plt.subplot(313)
plt.plot(fre, psd)
plt.xlabel('Frequency(Hz)', fontsize=14)
plt.ylabel('Power Spectrum Density(Watts/Hz)', fontsize =8)
plt.show()
np.savetxt( file ,y, delimiter=' ',newline=' ')
plt.savefig('FFT'+i+'.png', bbox_inches='tight')
wait = input("PRESS ENTER TO CONTINUE.") #an attempt at breakpoints
plt.figure
plt.subplot(111)
plt.plot(bin[0:bnn],his)
plt.show()
plt.savefig('Histogram'+i+'.png', bbox_inches='tight')
Even using plt.figure()
, I still plot overtop of existing plots unless I use plt.subplot(111)
, which erases the original plot and places the new one in the same window. I am hoping to generate two separate windows. I have read several previous questions to no avail. I tried using %matplotlib qt
or what I have imported mpl as, but also no use. Perhaps I do not understand the syntax for this?
First note that plt.figure
does nothing. You would need to call plt.figure()
. However, this is not solving the actual problem.
Since the old figure with 3 subplots is still the current figure at the point you want to start a new one, plt.figure()
will simply get you the old figure.
To get a new figure, use a new figure number.
plt.figure(2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.