Primer animacije slučajnih matrica:
HTML kod:
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import numpy as np
fig, ax = plt.subplots()
def x(): return np.random.randint(2,size=(5,4))
def update(i):
ax.imshow(x())
ax.set_axis_off()
print(x())
anim = FuncAnimation(fig, update, frames=20, interval=50)
plt.show()
kada se uradi print(x()) štampa se:
[[0 1 0 1]
[0 0 1 1]
[0 0 1 0]
[0 1 1 1]
[0 1 0 0]]
[[0 1 0 1]
[0 0 1 1]
[1 0 0 0]
[1 1 1 0]
[1 1 1 1]]
[[1 1 0 1]
[1 1 1 0]
[0 1 1 1]
[1 0 0 0]
[1 0 0 0]]
Kada uradim print (y) iz mojeg programa, tj. kada izdvojim tri matrice x[1008:1011] iz liste dobijam:
[[[1 1 1 1]
[1 1 1 1]
[1 1 0 0]
[0 0 0 0]
[1 1 1 1]]
[[1 1 1 1]
[1 1 1 1]
[1 1 0 0]
[0 0 0 0]
[1 1 1 0]]
[[1 1 1 1]
[1 1 1 1]
[1 1 0 0]
[0 0 0 0]
[1 1 0 1]]]
Mislim da je tu problem.