I've achieved the following plot with a combination networkx and graphviz:
I'm very happy with the result. In the plot you can identify what I call aggregation nodes: those are the latest green ones (where all the green nodes converge) one hop before the orange ones.
What I'd like to achieve is the following:
1) Put labels on the sides of the nodes. As you can see, the labels are over them and it's difficult to read;
2) Only show labels on the aggregation nodes and the orange ones.
This is how I get to plot the diagram.
# We create the graph
G = nx.DiGraph()
# We add nodes and edges
G.add_nodes_from(nodes)
G.add_edges_from(edges)
# We establish attributes to nodes
nx.set_node_attributes(G,nodesAttrDic)
# Tune plot
nodeFontSize = 10
nodeSize = 20
nodeColorList = list(getNodeColor(nodesAttrDic,G.nodes()))
edgeColorList = getEdgeColor(G.edges())
# Graphiz tunning
prog = 'dot'
args = '-Gnodesep=1 -Granksep=2 -Gpad=0.5 -Grankdir=TD'
root = None
pos = graphviz_layout(G, prog = prog, root = root, args = args)
nx.draw(G,
pos = pos,
with_labels = True,
node_color = nodeColorList,
edge_color = edgeColorList,
font_size = nodeFontSize,
node_size = nodeSize,)
plt.show()
Any ideas on how to do this?
Thanks!
Lucas
Ok, so I've partially solved the second question: how to plot from the aggregation nodes onwards. To do so I estimate the number of hops towards the latest one. After that I decide to label the nodes below the threshold.
UPDATE:
Now, in order to re-position the labels, I had to modify the position myself.
After this, I get to plot the following:
And I really like this output now ... :-)