Created
May 31, 2013 16:58
-
-
Save clayadavis/5686333 to your computer and use it in GitHub Desktop.
How to draw network layouts to files. Run this in a Python shell.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib | |
#This has to go before importing pyplot | |
matplotlib.use('Agg') | |
import matplotlib.pyplot as plt | |
import networkx as nx | |
# Make your graph | |
G = nx.dodecahedral_graph() | |
# There are many configuration options available for nx.draw | |
# http://networkx.github.io/documentation/latest/reference/generated/networkx.drawing.nx_pylab.draw_networkx.html#networkx.drawing.nx_pylab.draw_networkx | |
nx.draw(G) | |
plt.savefig('graph_image.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment