How do I save a new graph as png with every iteration of a loop
问题 I don't know how to save a new graph png for each iteration of a loop using NetworkX. I've borrowed the code from this question: in NetworkX cannot save a graph as jpg or png file and manipulated it a bit. Below is the code: import networkx as nx import matplotlib.pyplot as plt fig = plt.figure(figsize=(12,12)) ax = plt.subplot(111) ax.set_title('Graph - Shapes', fontsize=10) G = nx.DiGraph() G.add_node('shape1', level=1) G.add_node('shape2', level=2) G.add_node('shape3', level=2) G.add_node(