networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
draw_networkx_labels(G, pos, labels=None, font_size=12, font_color='k', font_family='sans-serif', font_weight='normal', alpha=None, bbox=None, horizontalalignment='center', verticalalignment='center', ax=None, clip_on=True)

Parameters

G : graph

A networkx graph

pos : dictionary

A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.

labels : dictionary (default={n: n for n in G})

Node labels in a dictionary of text labels keyed by node. Node-keys in labels should appear as keys in :None:None:`pos`. If needed use: :None:None:`{n:lab for n,lab in labels.items() if n in pos}`

font_size : int (default=12)

Font size for text labels

font_color : string (default='k' black)

Font color string

font_weight : string (default='normal')

Font weight

font_family : string (default='sans-serif')

Font family

alpha : float or None (default=None)

The text transparency

bbox : Matplotlib bbox, (default is Matplotlib's ax.text default)

Specify text box properties (e.g. shape, color etc.) for node labels.

horizontalalignment : string (default='center')

Horizontal alignment {'center', 'right', 'left'}

verticalalignment : string (default='center')

Vertical alignment {'center', 'top', 'bottom', 'baseline', 'center_baseline'}

ax : Matplotlib Axes object, optional

Draw the graph in the specified Matplotlib axes.

clip_on : bool (default=True)

Turn on clipping of node labels at axis boundaries

Returns

dict

:None:None:`dict` of labels keyed on the nodes

Draw node labels on the graph G.

See Also

draw
draw_networkx
draw_networkx_edge_labels
draw_networkx_edges
draw_networkx_nodes

Examples

>>> G = nx.dodecahedral_graph()
... labels = nx.draw_networkx_labels(G, pos=nx.spring_layout(G))

Also see the NetworkX drawing examples at https://networkx.org/documentation/latest/auto_examples/index.html

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.drawing.nx_pylab.draw_networkx networkx.drawing.nx_pylab.draw networkx.drawing.nx_pylab.draw_networkx_labels networkx.drawing.nx_pylab.draw_networkx_edge_labels networkx.drawing.nx_pylab.draw_networkx_edges networkx.drawing.nx_pylab.draw_networkx_nodes

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/drawing/nx_pylab.py#924
type: <class 'function'>
Commit: