0
我有一點麻煩,在代碼matplotlib.animation所示:創建從plt.imshow matplotlib動畫三聯供循環
# creates grid of 1's/-1's of dimensions specified.
arr1 = np.random.choice([1.,-1.],[xarray,yarray])
# arr will be the 2-d array iterated.
arr = arr1
# time, row and column loops.
for t in range(0,time1):
for i in range(0,x):
for j in range(0,y):
Echange=energy_change(arr,i,j) # change in energy for this flip.
P_flip = np.exp(-Echange/kT) # probability of this flip occurring.
if random.random() < P_flip: # condition to accept flip.
arr[i][j]=-1*arr[i][j]
image = plt.imshow(arr) # plots image of Ising model after (time) iterations.
if t==0:
plt.show()
else:
plt.draw()
我已刪除了我的清晰動畫嘗試。基本上我想製作一個在指定時間後停止的窗口化動畫,沒有任何計算延遲(運行此代碼顯示動畫,但不一致或平滑運行)。有沒有通過所有迭代計算的方法,然後顯示一個動畫窗口?我會感謝任何貢獻!