问题描述
我正在做我的毕业论文,我需要为许多不同的系统创建一些 gif,问题是我的代码真的很慢,我需要一种方法来提高速度,我正在使用 imageio 来做到这一点
fig,ax=plt.subplots()
plt.title("Variacion diaria")
plt.xlim(0,max(dia)+1)
plt.ylim(0,max(nstot)+1)
filenames=[]
plt.plot(nstot[:1],'b',label=("Susceptibles totales"))
plt.plot(nitot[:1],'r',label=("Infectados totales"))
plt.plot(nrtot[:1],'g',label=("Recuperados totales"))
plt.plot(ndtot[:1],'k',label=("Muertos totales"))
plt.legend()
for i in range(0,diax):
plt.plot(nstot[:i],'b')
plt.plot(nitot[:i],'r')
plt.plot(nrtot[:i],'g')
plt.plot(ndtot[:i],'k')
#Create frame and saving it
filename=f'{i}.png'
filenames.append(filename)
#save frame
plt.savefig(filename)
plt.close
#gif construction
with imageio.get_writer("gifprueba.gif",mode='?') as writer:
for filename in filenames:
image=imageio.imread(filename)
writer.append_data(image)
#Delete frames
for filename in set(filenames):
os.remove(filename)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)