Jan-10-2021, 01:01 PM
(This post was last modified: Jan-10-2021, 01:01 PM by Caffeine_Addict.)
Hello,
I'm trying to animate a 2D array, but it's not Working :(
Here is my code :
Thanks for help guys !
Edit : i forgot to tell you something strange : when i put a breakpoint on my updated function, the function is never reached.
I'm trying to animate a 2D array, but it's not Working :(
Here is my code :
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm, animation
INDEXTABLE = 20
fig, ax = plt.subplots()
i = 0
def updated(*args):
global i
if i < 99:
i += 1
else:
i = 0
img.set_data(alive(mat))
return img
def alive(mat):
#Some working stuff wo take a mat as parameter and return modified mat
return mat
mat = np.zeros((INDEXTABLE, INDEXTABLE))
#define a glider
mat[10, 10] = 1
mat[11, 11] = 1
mat[12, 9] = 1
mat[12, 10] = 1
mat[12, 11] = 1
img = ax.imshow(mat, interpolation='None', cmap='viridis', aspect='equal')
ani = animation.FuncAnimation(fig, updated, interval=50)
plt.show()I tried many things to make it working : change set data to set array, add parameters att updated function ... but i cant find the right SolutionThanks for help guys !
Edit : i forgot to tell you something strange : when i put a breakpoint on my updated function, the function is never reached.
