How to force node position (x and y) in graphviz

2019-01-07 08:58发布

I am trying to force position of nodes. I have x and y coordinates of my nodes and its also directed graph. I can use the rank=same to handle row (y coordinate), but can't figure out how I can handle column (x coordinate). Thanks in advance.

2条回答
放我归山
2楼-- · 2019-01-07 09:59

I couldn't get the -n flag work with dot -Kfdp.

I was however able to get it working with neato using the following command:

neato sample.dot -n -Tpng -o sample.png

查看更多
女痞
3楼-- · 2019-01-07 10:02

You can use pos attribute (https://www.graphviz.org/doc/info/attrs.html#d:pos), e.g.:

xxx [
    label = xxx
    pos = "0,0!"
]

yyy [
    label = yyy
    pos = "10,10!"
]

You will also have to specify neato or fdp layout engine, so that dot command-line would be (for fdp):

dot -Kfdp -n -Tpng -o sample.png sample.dot
查看更多
登录 后发表回答