Make graphviz nodes left aligned

I want the nodes in the second column (C and E) to align on the left, and not in the center.

digraph left { graph [rankdir="LR", splines=ortho]; node [shape=record]; l1 [label="A\l|B\l"]; l2 [label="C\l|short\l"]; l3 [label="E\l|long long text\l"]; l1 -> l2; l1 -> l3; } 

enter image description here

I saw this question .

But the proposed method of using constant width for nodes does not suit me. I want to have different widths depending on the corresponding width of the labels.

+5
source share
1 answer

It seems that the node position on the chart in all situations is calculated from the center. Until there is no other implementation, the only way to achieve a β€œaligned” appearance is to use a suitable width.

 digraph left { graph [rankdir=LR splines=ortho] node [shape=record] l1 [label="A\l|B\l"] l2 [label="C\l|short\l" width=1.3] l3 [label="E\l|long long text\l"] l1 -> l2 l1 -> l3 } 

leads to the following: enter image description here

0
source

Source: https://habr.com/ru/post/1205413/


All Articles