I am drawing a graph with around 5K nodes in it using networkX and matplotlib. The GTK window by matplotlib has tools to zoom and visualise the graph. Is there any way, I can save a magnified version for proper visualisation later?
import matplotlib.pyplot as plt
import networkx as nx
pos=nx.spring_layout(G) #G is my graph
nx.draw(G,pos,node_color='#A0CBE2',edge_color='#BB0000',width=2,edge_cmap=plt.cm.Blues,with_labels=True)
#plt.show()
plt.savefig("graph.png", dpi=500, facecolor='w', edgecolor='w',orientation='portrait', papertype=None, format=None,transparent=False, bbox_inches=None, pad_inches=0.1)
You have two easy options:
plt.savefig("graph.png", dpi=1000)
(larger image file size)
plt.savefig("graph.pdf")
This is the best option, as the final graph is not rasterized. In theory, you should be able to zoom in indefinitely.