python初心者です。jupytor notebookでmatplotlibを用いたアニメーションを試みております。入門書ででてきた下記のコードで、円が徐々に大きくなるアニメーションを作りたいのですが、jupytor notebook上で空白の軸だけがでてきて、アニメーションが表示されません。HTMLなど試しましたが、うまく動きません。
python3.6, MacOs Sierraを用いております。どのようにしたら解決できるのか、ご教示頂ければ幸いです。どうぞよろしくお願い申し上げます。
import matplotlib.pyplot as plt
from matplotlib import animation
def create_circle():
circle = plt.Circle((0,0), radius=0.05)
return circle
def update_radius(i, circle):
circle.radius = i*0.5
return circle,
def create_animation():
fig = plt.gcf()
ax = plt.axes(xlim=(-10,10), ylim=(-10,10))
ax.set_aspect('equal')
circle = create_circle()
ax.add_patch(circle)
anim = animation.FuncAnimation(fig, update_radius, fargs=(circle,),
frames=30, interval=50)
plt.title('Simple Circle Animation')
if name=='main':
create_animation()
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/18 09:33
退会済みユーザー
2018/02/18 11:01