使用pydot绘制方形线

时间:2012-11-14 18:30:20

标签: python python-2.7 graphviz pydot

我需要生成图表。我使用pydot库。我的代码是:

import pydot
people = ['person_%d'%i for i in range(10)]
graph = pydot.Dot(graph_type='graph', rankdir='LR', splines='ortho')
# create nodes for people
node_list = [] 
for person in people:
    node = pydot.Node(person, shape="record", style="filled", fillcolor="#E8E8E8")
    node_list.append(node)
# get parent node
parent_node = node_list.pop(0)
# create edges
for node in node_list:
    edge = pydot.Edge(parent_node, node, color="#B6B6B6")
   graph.add_edge(edge)
graph.write_png('chart.png')

执行此代码的结果是:

http://i49.tinypic.com/keu7mw.png

所以我需要改变以获得与下图相同(相似)的结果:

http://i48.tinypic.com/2115g0i.png

1 个答案:

答案 0 :(得分:0)

我现在无法测试,但确实

edge = pydot.Edge(parent_node, node, color="#B6B6B6", splines="ortho")

工作?