networkx.drawing.nx_pylab.draw_networkx_edges¶
-
draw_networkx_edges
(G, pos, edgelist=None, width=1.0, edge_color='k', style='solid', alpha=None, arrowstyle='-|>', arrowsize=10, edge_cmap=None, edge_vmin=None, edge_vmax=None, ax=None, arrows=True, label=None, node_size=300, nodelist=None, node_shape='o', connectionstyle=None, min_source_margin=0, min_target_margin=0, **kwds)[source]¶ Draw the edges of the graph G.
This draws only the edges of the graph G.
- 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.
edgelist (collection of edge tuples) – Draw only specified edges(default=G.edges())
width (float, or array of floats) – Line width of edges (default=1.0)
edge_color (color or array of colors (default=’k’)) – Edge color. Can be a single color or a sequence of colors with the same length as edgelist. Color can be string, or rgb (or rgba) tuple of floats from 0-1. If numeric values are specified they will be mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.
style (string) – Edge line style (default=’solid’) (solid|dashed|dotted,dashdot)
alpha (float) – The edge transparency (default=None)
edge_ cmap (Matplotlib colormap) – Colormap for mapping intensities of edges (default=None)
edge_vmin,edge_vmax (floats) – Minimum and maximum for edge colormap scaling (default=None)
ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.
arrows (bool, optional (default=True)) – For directed graphs, if True draw arrowheads. Note: Arrows will be the same color as edges.
arrowstyle (str, optional (default=’-|>’)) – For directed graphs, choose the style of the arrow heads. See :py:class:
matplotlib.patches.ArrowStyle
for more options.arrowsize (int, optional (default=10)) – For directed graphs, choose the size of the arrow head head’s length and width. See :py:class:
matplotlib.patches.FancyArrowPatch
for attributemutation_scale
for more info.connectionstyle (str, optional (default=None)) – Pass the connectionstyle parameter to create curved arc of rounding radius rad. For example, connectionstyle=’arc3,rad=0.2’. See :py:class:
matplotlib.patches.ConnectionStyle
and :py:class:matplotlib.patches.FancyArrowPatch
for more info.label ([None| string]) – Label for legend
min_source_margin (int, optional (default=0)) – The minimum margin (gap) at the begining of the edge at the source.
min_target_margin (int, optional (default=0)) – The minimum margin (gap) at the end of the edge at the target.
- Returns
matplotlib.collection.LineCollection –
LineCollection
of the edgeslist of matplotlib.patches.FancyArrowPatch –
FancyArrowPatch
instances of the directed edgesDepending whether the drawing includes arrows or not.
Notes
For directed graphs, arrows are drawn at the head end. Arrows can be turned off with keyword arrows=False. Be sure to include
node_size
as a keyword argument; arrows are drawn considering the size of nodes.Examples
>>> G = nx.dodecahedral_graph() >>> edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> G = nx.DiGraph() >>> G.add_edges_from([(1, 2), (1, 3), (2, 3)]) >>> arcs = nx.draw_networkx_edges(G, pos=nx.spring_layout(G)) >>> alphas = [0.3, 0.4, 0.5] >>> for i, arc in enumerate(arcs): # change alpha values of arcs ... arc.set_alpha(alphas[i])
Also see the NetworkX drawing examples at https://networkx.org/documentation/latest/auto_examples/index.html