in NetworkX cannot save a graph as jpg or png file
问题 I have a graph in NetworkX containing some info. After the graph is shown, I want to save it as jpg or png file. I used the matplotlib function savefig but when the image is saved, it does not contain anything. It is just a white image. Here is a sample code I wrote: 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