4
我的程序顯示了plt.show()
正確的圖形彈出,但不是在fig.savefig之一。如果它是簡單的,我對Python非常新,所以很抱歉。 我使用的是python 2.7.10,windows(10)。Matplotlib:在一個循環中保存的文件是不一樣的節目()
import numpy as np
import matplotlib.pyplot as plt
data = np.genfromtxt('strike_details.txt') #, skip_header= 0
header= 3
information=10000
width = 5
files = 16
types = 4
length = information + header
frames = data[header:length,0]
fig= plt.figure()
plt.grid(True)
for i in range(0,int(files)):
density=data[(header+i*length):(length+i*length),4]
plt.plot(frames,density, label=data[i*length+1][2])
for j in range (0,files/types):
if i==(types*(j+1)-1):
plt.legend(loc='best')
plt.xlabel('$Frames$', fontsize=22)
plt.ylabel('$Density$', fontsize=22)
fig.savefig(str(data[j*length+1][0])+'_'+str(data[j*length+1][1])+'_'+str(data[j*length+1][2])+'.png',format='png', dpi=fig.dpi)
plt.show()
plt.clf()
的程序產生四個文件具有不同的文件名,但他們都在你的plt.show彈出看到的第一組。
如果我錯過了任何重要的信息,請告訴我。
感謝,
廖氏
多少情節窗口彈出? –
四,一次一個。 (因爲在一個窗口彈出,關閉和下一個窗口) –