我试图在python中生成一个giF来表示一个图随时间的变化。然而,我正在为每个图获得单独的图(它们不是堆叠在同一个图上)。我是新的编码,并会欣赏任何见解。代码部分:
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0,t_final, dt)
x = np.linspace(dx/2, L-dx/2, n)
T1 = np.ones(n)*T0
dT1dt = np.zeros(n)
T2 = np.ones(n)*T0
dT2dt = np.zeros(n)
for j in range(1,len(t)):
plt.clf()
T1 = T1 + dT1dt*dt #T1 is an array
T2 = T2 + dT2dt*dt #T2 is an array
plt.figure(1)
plt.plot(x,T1,color='blue', label='Inside')
plt.plot(x,T2,color='red', label='Outside')
plt.axis([0, L, 298, 920])
plt.xlabel('Distance (m)')
plt.ylabel('Temperature (K)')
plt.show()
plt.pause(0.005)
字符串
1条答案
按热度按时间nnt7mjpx1#
您可以使用
imageio
库字符串
然后,
型
在那之后,在不同的脚本中,或者在相同的脚本中,如果你喜欢
型
然后,最后
型