I would like to animate a graph that grows over time.
This is what I have so far:
fig = plt.figure()
ims = []
graph = nx.Graph()
for i in range(50):
// Code to modify Graph
nx.draw(graph, pos=nx.get_node_attributes(graph,'Position'))
im = plt.draw()
self.ims.append([im])
ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True,repeat_delay=1000)
ani.save('dynamic_images.mp4')
plt.show()
However, I get the following error message:
File "main.py", line 204, in <module>
repeat_delay=1000)
File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 356, in __init__
TimedAnimation.__init__(self, fig, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 304, in __init__
Animation.__init__(self, fig, event_source=event_source, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 53, in __init__
self._init_draw()
File "/usr/lib/pymodules/python2.7/matplotlib/animation.py", line 363, in _init_draw
artist.set_visible(False)
AttributeError: 'NoneType' object has no attribute 'set_visible'
nicomoto@nicomoto-VirtualBox:~/Desktop/CS8903-SpecialProblem/Code/
What I want is an animation, where you can see the graph growing. I can save the graph at each stage, and might be able to create an animation outside matplotlib, but is there any way of getting it work like this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…