Custom Node Positions and Edge Paths

Node positions can be set explicitly by using a dictionary that maps node IDs to (x, y) coordinates as the node_layout keyword argument.

Analogously, edge paths can be set explicitly by using a dictionary that maps edge IDs to ndarray of (x, y) coordinates as the edge_layout keyword argument.

plot 07 custom layout
import numpy as np
import matplotlib.pyplot as plt

from netgraph import Graph

edge_list = [(0, 1)]
node_positions = {
    0 : (0.2, 0.4),
    1 : (0.8, 0.6)
}
edge_paths = {
    (0, 1) : np.array([(0.2, 0.4), (0.2, 0.8), (0.5, 0.8), (0.5, 0.2), (0.8, 0.2), (0.8, 0.6)])
}

Graph(edge_list, node_layout=node_positions, edge_layout=edge_paths)
plt.show()

Total running time of the script: ( 0 minutes 0.087 seconds)

Gallery generated by Sphinx-Gallery