How to specify where an edge connects to a node in Graphviz

458 Views Asked by At

I am trying to use Graphviz to create a family tree but the diagram that is created comes out kind of wonky. To clean up the diagram I tried to specify the headport, tailport and edge length for some of the connections but it doesn't look like its working.

Here is an image of my attempt to create a family tree with the names whited out. As you can see some of the edges and nodes are in the wrong place. enter image description here Here is my code where I try to specify the edge length, headport and tailport for the spousal relationships:

if len(this_gen) > 0:
    for j in range(0, len(this_gen)):
        # note x creates a dot in-between the couple that is used as a connection point for their kids
        with dot.subgraph() as subs:
            subs.attr(rank='same')
            subs.node(per1, per1, tooltip=det, shape=sh, fillcolor="black")
            node_nm.append(per1)
            subs.node(per2, per2, tooltip=det, shape=sh, fillcolor="black", tailport="e", headport="w")
            subs.node(x, x, tooltip=det, shape='point', fillcolor="black", tailport="e", headport="w")
            subs.edge(per1, x, arrowhead='none', color="black:invis:black",len="1", tailport="e", headport="w")
            subs.edge(x, per2, arrowhead='none', color="black:invis:black",len="1", tailport="e", headport="w")
            df.loc[df['prof_names'] == this_gen['prof_names'].iloc[j], 'recorded_ind'] = 1
0

There are 0 best solutions below