Created
March 22, 2018 12:23
-
-
Save tolgahanuzun/2127f7175183c91695ab68240608d268 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def save_graph(graph,file_name): | |
plt.figure(num=None, figsize=(15, 15), dpi=1000) | |
plt.axis('off') | |
fig = plt.figure(1) | |
pos = nx.spring_layout(graph,k=100,iterations=0,scale=0.001) | |
nx.draw_networkx_nodes(graph,pos,node_size=20,alpha=0.1,linewidths=0.1) | |
nx.draw_networkx_edges(graph,pos,alpha=0.5,width=0.1,style='dashdot') | |
nx.draw_networkx_labels(graph,pos,font_size=1) | |
cut = 1.30 | |
xmax = cut * max(xx for xx, yy in pos.values()) | |
ymax = cut * max(yy for xx, yy in pos.values()) | |
plt.xlim(-xmax, xmax) | |
plt.ylim(-ymax, ymax) | |
plt.savefig(file_name,bbox_inches="tight") | |
pylab.close() | |
del fig | |
if __name__ == "__main__": | |
data = json.load(open('private.txt')) | |
graph = generate_edges(data) | |
node = nodes_list(data) | |
G = nx.Graph() | |
G.add_nodes_from(node) | |
G.add_edges_from(graph) | |
save_graph(G,"my_graph.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment