-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanim.py
29 lines (23 loc) · 849 Bytes
/
anim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
class Anim:
def my_animation(self,solution, dt, Y, Z):
#################### Animation ####################
fig = plt.figure(figsize=(6.1,5),facecolor='w')
images=[]
lev=np.linspace(-1,1,50)
i=0
t=0
for sol in solution:
if i%50==0: # plots contour each 50 time steps
im=plt.contourf(Y,Z,sol[:], levels=lev,vmax=1.0,vmin=-1.0)
images.append(im.collections)
i+=1
t += dt
cbar = plt.colorbar()
plt.title('Velocity Contour')
#plt.clim(-1,1)
cbar.set_ticks(np.linspace(-1,1,50))
ani = animation.ArtistAnimation (fig, images, interval=35, blit= True, repeat_delay=50)
plt.show()