I am lost in all the python libraries for drawing graphs. I wish I knew one that is flexible and with documentation...
I have spent substantial time playing with networkx to find out that it is not as good for my task (e.g. overlapping labels for bigger graphs).
Now, I am trying to use pydot or pydotplus, but there is no documentation, no reasonable examples out there. Or am I missing something? Pydotplus website provides a reference, but that is not entirely helpful for a beginner.
Now, I am able to draw a graph with pydotplus, but I want to change the node positions (Fruchterman-Reingold algorithm) and especially use colors and sizes with nodes, but I have no idea how.
Sample code:
import pydotplus as ptp
graph = ptp.Dot(graph_type='graph')
edges = [(1,2), (1,3), (2,4), (2,5), (3,5)]
nodes = [(1, "A", "r"), (2, "B", "g"), (3, "C", "g"), (4, "D", "r"), (5, "E", "g")]
for e in edges:
graph.add_edge(ptp.Edge(e[0], e[1]))
for n in nodes:
node = ptp.Node(name=n[0], attrs={'label': n[1], 'fillcolor': n[2]} )
graph.add_node(node)
graph.write_png("file.png")
This throws an exception:
InvocationException: Program terminated with status: 1. stderr follows:
Error: /tmp/tmpznciMx: syntax error in line 7 near '{'