würde Ich mag eine Grafik animieren, das im Laufe der Zeit wächst.Animieren von Netzwerk-Wachstum mit NetworkX und Matplotlib
Dies ist, was ich bisher:
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()
Allerdings bekomme ich folgende Fehlermeldung:
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'
[email protected]:~/Desktop/CS8903-SpecialProblem/Code/
Was ich will, ist eine Animation, in dem Sie die Grafik wachsen sehen können. Ich kann das Diagramm in jeder Phase speichern und kann möglicherweise eine Animation außerhalb von Matplotlib erstellen, aber gibt es eine Möglichkeit, es so zu machen?
Was ist Ihr Backend? Ich habe einige Animationsprobleme mit einigen Backends festgestellt. Können Sie Matplotlibs [basic_example.py] (http://matplotlib.org/examples/animation/basic_example.html) ausführen? – tiago
Ja, das funktioniert perfekt für mich. Wie für das Backend, bin ich nur auf Ubuntu, Python 2.7, Numpy, Scipy, NetworkX und Matplotlib ... alle in den letzten Tagen installiert, so dass sie die neueste Version sind ... Ich bin im Grunde ein Student, und Ich probiere ein paar Experimente aus. Es wäre wirklich hilfreich, diese Grafiken zu animieren, damit ich sehen kann, wie sie wachsen! – Nicomoto
Ich bin nicht mit NetworkX vertraut. Vielleicht ist das Problem, dass 'ArtistAnimation' einen Matplotlib-Künstler und kein Nx-Objekt erwartet? – tiago