我想通过 for 循环绘制 n 个独立的图形,并将每个图形保存到一个文件中。我的代码如下:
import matplotlib.pyplot as plt
import numpy as np
for i in range(len(nfile)): #nfile is a list of file names
data = np.load(nfile[i])
plt.plot(data[0], data[1])
plt.savefig("figure_%d.png"%i, dpi=300)
我只想将 data[i] 的绘图显示在figure_i.png 中,但之前的绘图 (j=0, ..., i-1) 也显示在figure_i.png 中。有什么办法可以解决这个问题吗?
多谢!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)