Skip to main content
`Ctrl`+`K`

# draw_networkx_edge_labels

draw_networkx_edge_labels(G, pos, edge_labels=None, label_pos=0.5, font_size=10, font_color='k', font_family='sans-serif', font_weight='normal', alpha=None, bbox=None, horizontalalignment='center', verticalalignment='center', ax=None, rotate=True, clip_on=True, node_size=300, nodelist=None, connectionstyle='arc3', hide_ticks=True)

  Draw edge labels.

  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.

    edge_labels dictionary (default=None)

      Edge labels in a dictionary of labels keyed by edge two-tuple. Only labels for the keys in the dictionary are drawn.

    label_pos float (default=0.5)

      Position of edge label along edge (0=head, 0.5=center, 1=tail)

    font_size int (default=10)

      Font size for text labels

    font_color color (default=’k’ black)

      Font color string. Color can be string or rgb (or rgba) tuple of floats from 0-1.

    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, optional

      Specify text box properties (e.g. shape, color etc.) for edge labels. Default is {boxstyle=’round’, ec=(1.0, 1.0, 1.0), fc=(1.0, 1.0, 1.0)}.

    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.

    rotate bool (default=True)

      Rotate edge labels to lie parallel to edges

    clip_on bool (default=True)

      Turn on clipping of edge labels at axis boundaries

    node_size scalar or array (default=300)

      Size of nodes. If an array it must be the same length as nodelist.

    nodelist list, optional (default=G.nodes())

      This provides the node order for the `node_size` array (if it is an array).

    connectionstyle string or iterable of strings (default=”arc3”)

      Pass the connectionstyle parameter to create curved arc of rounding radius rad. For example, connectionstyle=’arc3,rad=0.2’. See `matplotlib.patches.ConnectionStyle` and `matplotlib.patches.FancyArrowPatch` for more info. If Iterable, index indicates i’th edge key of MultiGraph

    hide_ticks bool, optional

      Hide ticks of axes. When `True` (the default), ticks and ticklabels are removed from the axes. To set ticks and tick labels to the pyplot default, use `hide_ticks=False`.

  Returns:
    dict

      `dict` of labels keyed by edge

  See also

  `draw`
  `draw_networkx`
  `draw_networkx_nodes`
  `draw_networkx_edges`
  `draw_networkx_labels`

  Examples

      >>> G = nx.dodecahedral_graph()
      >>> edge_labels = nx.draw_networkx_edge_labels(G, pos=nx.spring_layout(G))

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