Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Animation with PIL

I want an animated picture. But I need a refresh-function because plt.show() always opens a new window. Does anybody have a hint? Thanks!

import numpy as np
import scipy
from scipy import *
import matplotlib.pyplot as plt

#array
aa = []
for x in range(44):
    aa.append([])
    for z in range(44):
        aa[x].append(3*sin(x/3.0)+2*cos(z/3.0))

b = aa
plt.imshow(b)
plt.show()

time = 0
dt = 0.1
while(time<3):
    b = sin(aa)
    time += dt
like image 552
kame Avatar asked Sep 04 '26 12:09

kame


1 Answers

PIL is geared towards image editing, not animating or displaying. Instead, look to a GUI toolkit or a multimedia library like pyglet or pygame

like image 102
Dan Passaro Avatar answered Sep 06 '26 01:09

Dan Passaro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!