如何从graphviz的布局中获取坐标? [英] How to get the coordinates from layout from graphviz?
问题描述
我已经在一些项目上使用pygraph.我完成了此示例,它工作正常.
现在,问题出在以下方面:图形以图片格式(gif)绘制.我需要的是获取gif图像上显示的图形布局的每个节点的实际坐标.我该怎么做呢?我一直在尝试,但是找不到解决此问题的方法.我认为该问题的解决方案将以某种方式处理以下两行之一:
gv.layout(gvv,'dot')
gv.render(gvv,'png','europe.png')
提前谢谢!
您可以使用以下命令将布局信息添加到图形中:
gv.render(gvv)
,然后找出获得其属性pos
的节点的位置:
n_france = gv.findnode(gvv, "France")
pos = gv.getv(n_france, "pos")
然后,根据您要执行的操作,可能需要将点坐标转换为png图像坐标.您可以从这里获取有用的信息:
http://www.graphviz.org/faq/#FaqCoordTransformation >
它详细解释了从图形单位到图像像素的计算.
希望这就是您想要的.
I have been working with pygraph on some project. I completed this example, it works fine.
Now, the problem is the following: the graph is drawn in a picture format (gif). What I need is to get the actual coordinates for each node for the graph layout shown on the gif image. How do I do this? I've been trying and trying, but couldn't find solution to this problem. I thought the the problem's solution would be somehow with manipulating one of the two following lines:
gv.layout(gvv,'dot')
gv.render(gvv,'png','europe.png')
Thanks in advance!
You can add the layout information into the graph with :
gv.render(gvv)
and then find out the position of a node getting its attribute pos
:
n_france = gv.findnode(gvv, "France")
pos = gv.getv(n_france, "pos")
Then depending on what you want to do, you might need to convert dot coordinates into png image coordinates. You can get useful information from here :
http://www.graphviz.org/faq/#FaqCoordTransformation
It explains in great details the computation from the graph-units to image pixels.
Hope that this is what you are looking for.
这篇关于如何从graphviz的布局中获取坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!