我需要从数值模型中生成 100 多个图(折线图)。到目前为止的代码正在生成循环内指定的图,但它不断向相同的 4 个图添加多行。我希望它完成 4 个绘图,然后打开一个新页面并一次又一次地绘制这 4 个绘图,所以我应该说 25 页总共 100 个绘图。
到目前为止的代码 - 我从小开始,想在 3 页上生成 12 个图并将其保存为文件“plot.pdf”:
from t2listing import *
import matplotlib.pylot as plt
from matplotlib.backends.backend_pdf import PdfPages
lst = t2listing('WAI1515PR_AW_407_ayfixold2.listing')
pdf_pages = PdfPages('plot.pdf')
feed = lst.generation.row_name
zone = feed[0:12]
sub = [221, 222, 223, 224]
for i in xrange(3):
fig = plt.figure()
for zone,sub in in zip(feed[0:12],(10/4+1)*sub):
(time, massflow) = lst.history([('g',zone,'Generation rate')])
ax1 = fig.add_subplot(sub)
ax1.plot(time, massflow, 'k-')
plt.ylabel('massflow kg/s')
plt.xlabel('time in seconds')
plt.title('GENER data')
plt.tight_layout()
plt.savefig('plot.pdf')
pdf_pages.savefig(fig)
pdf_pages.close()
到目前为止的结果是我得到了 4 个图,每个图上都有 3 个线图,有什么可能的方法来获得 12 个单独的图?