python中如何让图形出现在指定位置_python图形工具中的显式顶点位置

1586010002-jmsa.png

I am using python graph-tool. To draw graphs, it uses graph_draw function. I want to send vertex positions explicitly to dot engine. It turns out that I can pass a property map named pos. I tried defining it as v_pos = g.new_vertex_property("vector") where g is my graph. I am not sure if it is the right way to do it.

There is one code snippet which you might find helpful.

pos = gt.random_layout(g, shape=shape, dim=3)

>>> pos[g.vertex(0)].a

array([ 86.59969709, 1.31435598, 0.64651486])

graph_draw(g, pos=pos, output="graph-draw-random.pdf")

What should I do if I were to define my vertex position at (0,2), (0,4) ... (0,8)?

In above code snippet, I can change dim to 2. But I don't want random layout.

For reference, here is the home-page of this tool I am using. http://projects.skewed.de/graph-tool/

解决方案

You can set the positions trivially as follows:

pos = g.new_vertex_property("vector")

pos[g.vertex(0)] = (0, 2)

pos[g.vertex(1)] = (0, 4)

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值