Graphviz - Python:使用Graphviz将节点形状制作成双椭圆形

时间:2017-02-01 01:59:56

标签: python graphviz

我在我的python脚本中使用Graphviz 0.5.2,这与此

类似
from graphviz import Digraph
dot = Digraph()
dot.node('A', 'King Arthur', shape='ellipse')
dot.node('B', 'Sir Bedevere the Wise', shape='ellipse')
dot.node('L', 'Sir Lancelot the Brave', shape='ellipse')

dot.edges(['AB', 'AL'])
dot.edge('B', 'L', constraint='false')
dot.render('test-output/round-table.gv', view=True)

它呈现了这个:

enter image description here

默认情况下,节点的形状是椭圆/椭圆形,但我想使它成为一个双椭圆形,有一个双圆形但不是椭圆形。

我试过peripheries = 2,但我不确定是否适合放置它。

1 个答案:

答案 0 :(得分:4)

将外围应用于节点属性,例如

graph ethane {
node[ peripheries=5];
     C_0 -- H_0 [type=s];
     C_0 -- H_1 [type=s];
     C_0 -- H_2 [type=s];
     C_0 -- C_1 [type=s];
     C_1 -- H_3 [type=s];
     C_1 -- H_4 [type=s];
     C_1 -- H_5 [type=s];
 }

请参阅chart

在python中如果我理解了这些例子

dot.node_attr['peripheries']='5' #whole graph
n.attr['peripheries']='5' #any single node n

https://github.com/pygraphviz/pygraphviz/blob/master/examples/star.py