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):
As the existing answers are quite old, here is a version of how the code could look like with current versions of matplotlib and networkx.
import random
import networkx as nx
import matplotlib.pyplot as plt
graph = nx.Graph()
num_plots = 50
for node_number in range(num_plots):
graph.add_node(node_number, Position=(random.randrange(0, 100), random.randrange(0, 100)))
graph.add_edge(node_number, random.choice(list(graph.nodes())))
nx.draw(graph, pos=nx.get_node_attributes(graph,'Position'))
plt.pause(0.5)