Masroor
Masroor

Reputation: 908

Move a graphviz node to north-west (top-left) corner

I have the following code.

digraph topleft {
    graph [rankdir="LR", splines=ortho];
    node [shape=record];

    l1 [label="A\l|b\l"];
    l2 [label="C\l|d\l"];
    l3 [label="E\l|f\l"];
    l4 [label="G\l|h\l"];
    l5 [label="I\l|j\l"];
    l6 [label="K\l|l\l"];

    l1 -> l2 -> l6;
    l1 -> l3;
    l1 -> l4;
    l1 -> l5;
}

enter image description here

I want node A to be moved to top-left corner and at the same time maintain the same rank status for nodes C, E, G and I.

How do I do this?

Upvotes: 0

Views: 1053

Answers (1)

marapet
marapet

Reputation: 56526

You may simply add a group attribute with the same value to l1, l2 and l6:

digraph topleft {
    graph [rankdir="LR", splines=ortho];
    node [shape=record];

    l1 [label="A\l|b\l", group="a"];
    l2 [label="C\l|d\l", group="a"];
    l3 [label="E\l|f\l"];
    l4 [label="G\l|h\l"];
    l5 [label="I\l|j\l"];
    l6 [label="K\l|l\l", group="a"];

    l1 -> l2 -> l6;
    l1 -> l3;
    l1 -> l4;
    l1 -> l5;
}

Graphivz tries to render nodes belonging to the same group in a straight line, which moves l1 up to the left upper corner.

Upvotes: 1

Related Questions