【发布时间】:2021-07-15 05:45:10
【问题描述】:
我在 python 中有一个这样的算法:
For i in range(400,500):
if(avg<50):
plt.plot(x,y)
plt.savefig(image.png)
else:
plt.plot(x1,y1)
plt.savefig(image.png)
现在,如果没有循环,我会保存一个情节。但是在每次迭代中,我都使用另一个数据数组,因此会出现不同的图。我面临的问题是保存的图形在下一次迭代中不断被新的图形替换,而我想要的是保存在一个目录中的所有图。有人可以指导我吗?
【问题讨论】:
标签: python arrays loops matplotlib if-statement