【问题标题】:How to add an annotation outside of a node in Graphviz' dot?如何在 Graphviz 点中的节点之外添加注释?
【发布时间】:2014-05-25 23:14:56
【问题描述】:

我对 Dot 非常陌生,并试图在 Eclipse 中使用 Dot 和 Zest 可视化调用图。我想用某种注释来注释节点(图片上的 OK 和 Failed。)。

对于 Dot 或 Zest 有什么常用的方法吗?

【问题讨论】:

    标签: eclipse graphviz dot zest


    【解决方案1】:

    xlabel

    看看xlabel(外部标签)。

    main.dot

    graph {
        node [shape=square];
        1 [xlabel="a"]
        2 [xlabel="b"]
        1 -- 2;
    }
    

    转换:

    dot -Tpng main.dot > main.png
    

    输出:

    但不确定使用此方法控制准确的标签放置有多容易:即使默认情况下也会发生重叠。见:

    shape=record

    我只是更喜欢https://stackoverflow.com/a/23031506/895245 提到的shape=record 方法或它们的泛化,类似HTML 的标签,因为它更清楚每个节点属于什么标签:

    graph {
        rankdir=LR
        node [shape=record];
        1 [label="1|a"]
        2 [label="2|b"]
        1 -- 2;
    }
    

    输出:

    TODO 你能避免输入1 和2 两次吗?

    在 Ubuntu 16.10、graphviz 2.38 上测试。

    【讨论】:

      【解决方案2】:

      Zest 渲染不支持它,但在 DOT 级别上,您可以使用基于记录的节点:

      rankdir=LR;
      node [shape=record];
      m1[label="void m1()|OK"];
      m1[label="void m2()|Failed"];
      

      详情见http://www.graphviz.org/doc/info/shapes.html#record

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-07-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多