Graphviz:将边缘标签放在另一侧

发布于 2024-09-14 02:28:40 字数 562 浏览 8 评论 0原文

这可能与 如何在 graphviz 中将边标签放置在边上有关:我有以下图表,我使用命令 dot -Teps g.dot > 进行可视化g.eps:

graph triple {
    node [shape=box]; User; Object; Tag;
    node [shape=diamond,style=filled]; Triple;
    {
        User -- Triple [label = "1"];
        Object -- Triple [label = "1"];
    }
    {
        rank=same;
        User;
        Object;
    }
    Triple -- Tag [label="n"];
}

我希望通过将标签放在图表左侧的 User 和 Triple 之间,使结果更加对称。

This may be related to How to place edge labels ON edge in graphviz: I have the following graph, which I visualize using the command dot -Teps g.dot > g.eps:

graph triple {
    node [shape=box]; User; Object; Tag;
    node [shape=diamond,style=filled]; Triple;
    {
        User -- Triple [label = "1"];
        Object -- Triple [label = "1"];
    }
    {
        rank=same;
        User;
        Object;
    }
    Triple -- Tag [label="n"];
}

I would like the result to be more symmetric by putting the label between User and Triple on the left side of the graph.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

何时共饮酒 2024-09-21 02:28:40

graphviz 无法手动放置边缘标签。

但是,您可以使用 headlabellabeldistancelabelangle 属性:

graph triple {
node [shape=box]; User; Object; Tag;
node [shape=diamond,style=filled]; Triple;
    {
        User   -- Triple [headlabel = "1", labeldistance=2.5, labelangle=20];
        Object -- Triple [headlabel = "1", labeldistance=2.5, labelangle=-20];
    }
    {
        rank=same;
        User;
        Object;
    }
    Triple -- Tag [label="n"];
}

输出:

graphviz 输出

Manual placement of edge labels cannot be done with graphviz.

However, you could use the headlabel, labeldistance and labelangle attributes:

graph triple {
node [shape=box]; User; Object; Tag;
node [shape=diamond,style=filled]; Triple;
    {
        User   -- Triple [headlabel = "1", labeldistance=2.5, labelangle=20];
        Object -- Triple [headlabel = "1", labeldistance=2.5, labelangle=-20];
    }
    {
        rank=same;
        User;
        Object;
    }
    Triple -- Tag [label="n"];
}

Output:

graphviz output

↙厌世 2024-09-21 02:28:40

这是使用 splines=false 和双边的第二个解决方法:

graph {
splines=false;
node [shape=box]; User; Object; Tag;
node [shape=diamond,style=filled]; Triple;
    {
        User   -- Triple [label = "1"];
        User   -- Triple [label = ""];
        Object -- Triple [label = ""];
        Object -- Triple [label = "1"];
    }
    {
        rank=same;
        User;
        Object;
    }
    Triple -- Tag [label="n"];
}

输出:

alt text

And here's the second workaround using splines=false and double edges:

graph {
splines=false;
node [shape=box]; User; Object; Tag;
node [shape=diamond,style=filled]; Triple;
    {
        User   -- Triple [label = "1"];
        User   -- Triple [label = ""];
        Object -- Triple [label = ""];
        Object -- Triple [label = "1"];
    }
    {
        rank=same;
        User;
        Object;
    }
    Triple -- Tag [label="n"];
}

Output:

alt text

﹉夏雨初晴づ 2024-09-21 02:28:40

我放弃了让它在 Graphviz 中工作的尝试。相反,我渲染为 pdf,自己标记 pdf 以添加标签,然后将 pdf 拼合为新 pdf,这样标记将成为 pdf 的一部分。

I gave up trying to get it to work in Graphviz. Instead, I rendered as a pdf, marked up the pdf to add labels myself, and then flattened the pdf into a new pdf so the markups would be part of the pdf.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文