draw_spectral¶
- draw_spectral(G, **kwargs)[source]¶
Draw the graph
G
with a spectral 2D layout.This is a convenience function equivalent to:
nx.draw(G, pos=nx.spectral_layout(G), **kwargs)
For more information about how node positions are determined, see
spectral_layout
.- Parameters
- Ggraph
A networkx graph
- kwargsoptional keywords
See
draw_networkx
for a description of optional keywords.
See also
Notes
The layout is computed each time this function is called. For repeated drawing it is much more efficient to call
spectral_layout
directly and reuse the result:>>> G = nx.complete_graph(5) >>> pos = nx.spectral_layout(G) >>> nx.draw(G, pos=pos) # Draw the original graph >>> # Draw a subgraph, reusing the same node positions >>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")