Categories

# Towards new network graph visualisation – Python

Without much explanation, this is something which will help me work on a new layout algorithm to display my network graphs…

This is how you initiate the process of drawing the nodes and the edges, all I need to do next is figure out a way of calculating the coordinates for each based on a few parameters.

```import matplotlib
import matplotlib.pyplot as plt

tuple_node_coords = ([1,1],
[2,2],
[3,1])

tuple_edges_coords = (([1,1],[2,2]),
([2,2],[3,1]))

# create the canvas
fig = plt.figure()

# plot the edges first so that they apear behind the nodes.
# this looks more complicate than it should be because of the
# way the plot function handels coordinate, in that you need
# a full list for x and a full list for y, which is inconvenient
# when writing the file...hence this loop
for each_coord in tuple_edges_coords:
list_x_coords = []
list_y_coords = []
for coord_items in each_coord:
list_x_coords.append(coord_items[0])
list_y_coords.append(coord_items[1])
# finally! plot the edges
ax.plot(list_x_coords,list_y_coords)

# plot the nodes
for list_each_node in tuple_node_coords:
ax.plot(list_each_node[0],list_each_node[1],'o')

plt.show()
```