1

我需要生成一个图表。我使用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

4

1 回答 1

0

我现在无法测试它,但可以

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

工作?

于 2012-11-14T19:32:29.730 回答