使用pyDot生成图形时是否可以控制线角 [英] Is there a way to control line angle when producing graphs with pyDot

查看:121
本文介绍了使用pyDot生成图形时是否可以控制线角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个python类来显示和设置二进制搜索树的动画.但是,由pyDot edge和node命令生成的图形似乎不允许我控制连接树的每个元素的箭头的角度或方向.

I wrote a python class to display and animate binary search trees. Yet the graphs produced by the pyDot edge and node commands don't seem to allow me to control the angle or direction of the arrows connecting each element of my tree.

有许多控制节点形状的控件,但似乎没有任何关于线角度的控件.我希望找到某种最小角度参数,以便在将其添加到图形时将其添加到我的边缘?

There are lots of controls for shape of the nodes but there does not seem to be any control for angle of the lines. I was hoping to find some kind of minimum angle parameter to add to my edges as they are added to the graph?

这是我的代码示例,其中我使用edge命令绘制节点:

This is a sample of my code where I draw nodes using the edge command:

def draw(parent_name, child_name):
    # color for lines = red
    edge = pydot.Edge(parent_name, child_name, color="#ff0000")
    graph.add_edge(edge)

最终结果是,当几个节点只有一个孩子时,我的二叉搜索树图看起来不像传统的树结构.

The end result is that my graphs for binary search trees don't look like the traditional tree structures when several nodes have only one child.

这里是指向我的项目的链接,您可以在其中看到其他有效的结果: http://www.embeddedcomponents.com/blogs/2013/12/visualizing-software-tree-structures/

Here is a link to my project where you can see the otherwise working results: http://www.embeddedcomponents.com/blogs/2013/12/visualizing-software-tree-structures/

推荐答案

:

create会将图形写入临时点文件并进行处理 使用"prog"(默认为"twopi")给出的程序, 读取Postscript输出并将其作为字符串返回是 操作成功.

create will write the graph to a temporary dot file and process it with the program given by 'prog' (which defaults to 'twopi'), reading the Postscript output and returning it as a string is the operation is successful.

不可能使用点直接直接控制边缘天使语言,但添加不可见的边缘可以为您提供所需的结果,请参见示例

it is not possible to directly control edges angels using the dot language, but adding invisible edges can give you the result you want, see an example here that generates the following graph:

这篇关于使用pyDot生成图形时是否可以控制线角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆