[英]How to create new windows for subsequent matplotlib plots?
Currently using Python 3.6.0 |Continuum Analytics, Inc.| 当前正在使用Python 3.6.0 | Continuum Analytics,Inc. | (default, Dec 23 2016, 11:57:41) on Windows (64 bits).
(预设为2016年12月23日,11:57:41)在Windows(64位元)上。
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. 即使使用
plt.figure()
,我仍然会绘制现有图的plt.subplot(111)
除非使用plt.subplot(111)
,它会删除原始图并将新图放置在同一窗口中。 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. 我尝试使用
%matplotlib qt
或我导入的mpl as,但也没有用。 Perhaps I do not understand the syntax for this? 也许我不理解其语法?
First note that plt.figure
does nothing. 首先请注意,
plt.figure
不会执行任何操作。 You would need to call plt.figure()
. 您将需要调用
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. 由于具有3
plt.figure()
图的旧图形仍然是您要开始新图形时的当前图形,因此plt.figure()
只会为您提供旧图形。
To get a new figure, use a new figure number. 要获得新的图形,请使用新的图形编号。
plt.figure(2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.