現在、matplotlibのanimationを使って円をだんだん大きくするアニメーションを作成しようとしているのですが、うまくいきません。
ご教授お願いします。
円が出力されることから、アニメーションの部分に問題があると思われます。
update_circle()の部分がインクリメントされないことが問題かと思います。
よろしくお願いします。
python
1""" 2growing circle 3""" 4 5from matplotlib import pyplot as plt 6from matplotlib import animation 7 8 9def create_circle(): 10 circle = plt.Circle((0,0),5) 11 return circle 12 13 14def update_radius(i, circle): 15 circle.radius = i*0.5 16 return circle, 17 18 19def create_animation(): 20 fig = plt.gcf() 21 ax = plt.axes(xlim=(-10,10),ylim=(-10,10)) 22 ax.set_aspect('equal') 23 circle = create_circle() 24 ax.add_patch(circle) 25 anim = animation.FuncAnimation(fig, update_radius, fargs=(circle,), frames=30, interval=50) 26 plt.title('Simple circle animation') 27 plt.show() 28 29 30if __name__ == '__main__': 31 create_animation() 32
回答1件
あなたの回答
tips
プレビュー