私は時間の経過と共に変化するnetworkxグラフのアニメーションを制作しようとしています。私はnetworkx_drawユーティリティを使ってグラフのmatplotlibを作成し、matplotlibのArtistAnimationモジュールを使ってnetworkxが作ったアーティストからアニメーションを作成しています。私は私がここでやっているの最小再生作った:数値は住んで表示しながらmatplotlib ArtistAnimationが空のビデオを返します
import numpy as np
import networkx as nx
import matplotlib.animation as animation
import matplotlib.pyplot as plt
# Instantiate the graph model
G = nx.Graph()
G.add_edge(1, 2)
# Keep track of highest node ID
G.maxNode = 2
fig = plt.figure()
nx.draw(G)
ims = []
for timeStep in xrange(10):
G.add_edge(G.maxNode,G.maxNode+1)
G.maxNode += 1
pos = nx.drawing.spring_layout(G)
nodes = nx.drawing.draw_networkx_nodes(G, pos)
lines = nx.drawing.draw_networkx_edges(G, pos)
ims.append((nodes,lines,))
plt.pause(.2)
plt.cla()
im_ani = animation.ArtistAnimation(fig, ims, interval=200, repeat_delay=3000,blit=True)
im_ani.save('im.mp4', metadata={'artist':'Guido'})
プロセスが正常に動作しますが、それはまさに私が欲しいのアニメーションを生成します。また、アニメーションの処理がうまくいくことを示唆している、スクリプトの最後に図形でループアニメーションが生成されます。しかし、ディスクに保存された "im.mp4"ファイルを開くと、それは空白の白い画像であり、予想された時間稼働し、ライブで表示されたグラフ画像は一切表示されません。
私はnetworkxバージョン1.11とmatplotlibバージョン2.0を使用しています。私はアニメーションにffmpegを使用しており、Mac、OSX 10.12.3で動作しています。
私は間違って何をしていますか?