Reputation: 3021
I am using networkx to plot graph in python. However, my output is too dense. Is there any ways to sparse the graph? Below is my command in python.Thanks
pos=nx.spring_layout(self.G)
nx.draw_networkx_nodes(self.G,pos)
edge_labels=dict([((u,v,),d['weight'])
for u,v,d in self.G.edges(data=True)])
nx.draw_networkx_labels(self.G,pos, font_size=20,font_family='sans-serif')
nx.draw_networkx_edges(self.G,pos)
plt.axis('off')
#nx.draw_networkx_labels(self.G,pos, font_size=20,font_family='sans-serif')
nx.draw_networkx_edge_labels(self.G,pos,edge_labels=edge_labels)
nx.draw(self.G,pos, edge_cmap=plt.cm.Reds)
plt.show()
Upvotes: 2
Views: 2927
Reputation: 11484
You can also try Graphviz via PyDot (I prefer this one) or PyGraphviz.
In case you are interested in a publication-ready result, you can use the toolchain networkx
-> pydot
+ dot
-> dot2tex
+ dot
-> dot2texi.sty
-> TikZ
. Instead of this fragile toolchain, you can alternatively export directly to TikZ
with nx2tikz
(I've written it, so I'm biased) and use the graph layout algorithms that have been relatively recently added to TikZ
.
Upvotes: 2
Reputation: 3021
After I check some information from the documentation here: http://networkx.github.io/documentation/latest/reference/drawing.html#module-networkx.drawing.layout
I changed the format of layout to
pos=nx.circular_layout(self.G, scale=5)
and it works!
Upvotes: 0