I am trying to produce a giF to represent the change of a plot over time in python. However, I am getting separate plots for each graph (they are not stacking on the same plot). I am fresh at coding and would appreciate any insight. The part of the code:
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)