【问题标题】:Graphviz - Python : Making node shape into double ellipse with GraphvizGraphviz - Python:使用 Graphviz 将节点形状变成双椭圆
【发布时间】:2017-02-01 11:25:46
【问题描述】:

我在我的 python 脚本中使用Graphviz 0.5.2 with,与此类似

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)

它呈现这个:

默认情况下,节点的形状是椭圆/椭圆,但我想将其设为双椭圆,有双圆形但不是椭圆。

我已经尝试过peripheries = 2,但我不确定放置它的正确位置。

【问题讨论】:

    标签: python graphviz


    【解决方案1】:

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

    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

    【讨论】:

    • 如果您不介意我再问一次,我怎样才能将其仅应用于其中一个节点而不是所有节点?
    猜你喜欢
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-13
    • 2016-04-17
    • 2011-11-08
    • 2011-09-07
    相关资源
    最近更新 更多