Python 使用pydot绘制正方形线
我需要生成一个图表。我使用Python 使用pydot绘制正方形线,python,python-2.7,graphviz,pydot,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, sha
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')
执行此代码的结果是:
因此,我需要更改什么,以获得与下图相同(类似)的结果:
我现在无法测试它,但可以
edge = pydot.Edge(parent_node, node, color="#B6B6B6", splines="ortho")
工作?从pydot&graphviz的文档和示例图像来看,它看起来不像生成您想要的图形。您可能可以通过创建虚拟节点来伪造它,但我对此表示怀疑。我看到了一些关于虚拟节点的评论,但我认为有更简单的方法来实现。