Reputation: 185
How to make the following picture more visible. There are two problems. The blue dots are so small, I need a way to make a dot size sufficiently large to include the largest label (and thus all the other labels). On the other hand, some edges are too short. How to fix that?
The code I've used to create this graph is:
nx.draw(graph, pos = nx.spring_layout(graph), with_labels = True)
Upvotes: 4
Views: 4449
Reputation: 88226
For the node spacing, nx.spring_layout
has a parameter (k
) to adjust the spacing between nodes, the higher the more spacing. For the other parameters, you could improve the graph visibility by reducing the edge width and also by increasing the node size using the corresponding parameters in nx.draw
. Here's an example using a random graph:
from matplotlib import pyplot as plt
G = nx.fast_gnp_random_graph(100, .05)
plt.figure(figsize=(10,6))
pos = nx.spring_layout(G, k=0.8)
nx.draw(G, pos , with_labels = True, width=0.4,
node_color='lightblue', node_size=400)
Upvotes: 4