dynamicalab.drawing.draw_curved_edges

dynamicalab.drawing.draw_curved_edges(edges, pos, ax, mu=0.05, edge_color='black', edge_width=1.0, alpha=1.0, arrow_scale=20.0, loopsize=0)[source]

This function plots the edges of a graph with a certain curvature. It can also plot arrows for direction. For self-loop, it is possible to plot an edge that does a circle passing through the node. The size of the circle is controlled by the parameter loopsize.

Parameters

edges : list
A list of edges in the tuple format of node ids, (nodeA, nodeB).
pos : dict
A dictionary of nodes position.
ax : Matplotlib Axes object
Draw the edges in the specified Matplotlib axes.
mu : float : (default=0.05)
Level of curvature. Should always be positive. If zero, then edges are straight.
edge_color : str or list : (default=”black”)
If a list, then each entry is the color of the edge when iterated through edges. If a string, then each edge will have the same color.
alpha : float : (default=1)
Edges opacity.
arrow_scale : float : (default=20)
Control the size of the arrows. If equal to zero, then the arrows are invisible.
loopsize : float : (default=0)
If edges contains self-loops, i.e. edge==(nodeA, nodeA), then it draw a self-loop which is composed of a simple circle. The radius of the circle is controlled by loopsize

Example

import networkx as nx
import dynamicalab.drawing as draw
import matplotlib.pyplot as plt

G = nx.erdos_renyi_graph(20,0.1)
pos = nx.spring_layout(G)
edges = G.edges()

fig = plt.figure()
ax = plt.gca()

draw.draw_curved_edges(edges, pos, ax, mu=5)

plt.show()

See also

draw_networks