Search code examples
graphvizneato

Graphviz -- Scaling of neato display


Consider

digraph G {
   0[pos="0,0!"]
   1[pos="-2,3!"]
   2[pos="2,3!"]
   0->1[label="0.5"]
   0->2[label="0.5"]
   1->2[label="0.5"]
}

Under neato, this gives:

enter image description here

In my application, I have coordinates that are 10 times the coordinates here. That is 0 is at coordinates (0,0), 1 at (-20,30) and 2 at (20,30).

With

digraph G {
   0[pos="0,0!"]
   1[pos="-20,30!"]
   2[pos="20,30!"]
   0->1[label="0.5"]
   0->2[label="0.5"]
   1->2[label="0.5"]
}

the rendered graph becomes very "distant" so that the node labels and the arc labels are rendered in very small font.

enter image description here

Is there a way to control the scaling of the graphs so that even with magnification at 10 times (i.e., with coordinates an order of magnitude higher), as long as the relative positions of the nodes are unchanged (i.e., the coordinates are scaled by a constant multiplicative factor), the rendering is visible equally well as before? I could scale the coordinates manually by dividing every coordinate I obtain from my application by 10. Before that, I would like to know it the rendering engine can take care of this for me by itself.

Note: all of the rendering has been done at the online engine: https://dreampuf.github.io/GraphvizOnline/


Solution

  • The scale attribute seems to be what you want (https://graphviz.org/docs/attrs/scale/) Try neato -s10 -T... myfile.gv