2016-11-14 20 views
0

matplotlibを使用してアニメーションを生成するコードは次のとおりです。 Jupyterのノートブックで実行すると、アニメーショングラフの下に別の静的グラフも表示されます。どうすれば削除できますか?matplotlib.animationから静的グラフを取り除く方法を教えてください。

import numpy as np 
import matplotlib.pyplot as plt 
from matplotlib.animation import FuncAnimation 
from IPython.display import HTML 

fig, ax = plt.subplots() 

x = np.arange(0, 20, 0.1) 
ax.scatter(x, x + np.random.normal(0, 3.0, len(x))) 
line, = ax.plot(x, x - 5, 'r-', linewidth=2) 

def update(i): 
    label = 'timestep {0}'.format(i) 
    line.set_ydata(x - 5 + i) 
    ax.set_xlabel(label) 
    return line, ax 

anim = FuncAnimation(fig, update, frames=np.arange(0, 10), interval=200) 
HTML(anim.to_html5_video()) 

答えて

0

私は(this example notebook from the Authorを参照)JSAnimationと呼ばれるモジュールを使用します。 アニメーションを表示するには、

from JSAnimation.IPython_display import display_animation 
display_animation(anim) 
関連する問題