1

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: Twopi graphviz layout

What would be the best to show this without having the nodes of employee names overlap. Setting nodesep does not seem to affect anything

Bijan
  • 7,737
  • 18
  • 89
  • 149
  • I know this issue, my feature request is that twopi can arrange text in a radial order, so long text points away/ towards the middle. Maybe you can add your support on my request (from a long time ago, don't remember where it is now) or go to graphviz and add this feature request. I will add my support on your request. – Veritas_in_Numeris Feb 17 '23 at 18:01

1 Answers1

0

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.

sroush
  • 5,375
  • 2
  • 5
  • 11