下記のようなコードでanimationを作ろうと考えています。
しかしいざ走らせると、エラーは出ないのですがanimationが再生されません。(macbook pro メモリ8GB,jupyter notebook)
詳しい方がいらっしゃれば、ご教授をお願いします。
※dataはarrayになっています
※画像の中の一部をルンバ(?)のように掃くようにanimationを作りたいと考えています
import numpy as np
import matplotlib.pyplot as plt
import aotools #研究で使っているライブラリです
r0=0.05 # Fried parameter/平坦波面長[m] @500nm
N=1000 #resolution[pix]
delta=0.001 #[m/pix]
L0=100 #[m]
l0=0.01 #[m]
phase1=aotools.turbulence.phasescreen.ft_phase_screen(r0, N, delta, L0,l0,FFT=None, seed=None)*500/2.0/np.pi #in [nm]
fig=plt.figure(figsize=(30,10))
ax1=fig.add_subplot(121)
im1=ax1.imshow(phase1, origin='lower', cmap='rainbow'); ax1.axis('off'); ax1.set_title('Phase')
fig.colorbar(im1) # side_color_bar
plt.show() #画像作成
data = np.array(phase1)
a=data[400:600,0:1000]
fig=plt.figure(figsize=(30,10))
ax2=fig.add_subplot(121)
im2=ax2.imshow(a, origin='lower', cmap='rainbow'); ax2.axis('off')
plt.show() #画像の真ん中を細く切り出す
%matplotlib nbagg
import matplotlib.animation as animation
fig=plt.figure(figsize=(18,6))
ax=fig.add_subplot(121)
ims=[]
for i in range(0,800,1):
c=data[400:600,i:i+200]
im=ax.imshow(c, origin='lower', cmap='rainbow'); ax.axis('off')
ims.append(im)
ani = animation.ArtistAnimation(fig, ims, interval=100,repeat_delay=1000,blit=False)
plt.show() #上で切り出した画像を左から見ていくようにanimationしたい
あなたの回答
tips
プレビュー