Reputation: 8586
I have a Dataframe that links Employee
to Supervisor
and I am trying to create a twopi
Graphviz to create a radial org chart. I am having issues where some of the nodes overlap. Here is my current code:
from networkx.drawing.nx_agraph import to_agraph
G = nx.from_pandas_edgelist(df, source='Supervisor', target='Employee',create_using=nx.DiGraph)
A = to_agraph(G)
A.graph_attr['splines']='curved'
A.graph_attr['ranksep']="4"
for node in A:
# Style node to have color
n = A.get_node(node)
n.attr['style']='filled'
n.attr['fillcolor'] = '#ab9beb'
A.layout('twopi')
A.draw('layouts/twopi.png')
Here is what the output looks like:
What would be the best to show this without having the nodes of employee names overlap. Setting nodesep
does not seem to affect anything
Upvotes: 2
Views: 348
Reputation: 6763
This seems to be a "feature" of twopi - see the Graphviz gallery (https://graphviz.org/gallery/). The documentation says nodesep works "differently" for twopi.
Maybe neato would work better - though neato needs fiddling with mode & model attributes.
Upvotes: 0