Graphviz:将图表与其标签对齐

发布于 2025-01-17 04:16:52 字数 496 浏览 6 评论 0原文

默认情况下,Graphviz 将图形相对于其标题(标签)居中:

graph {
    label="lorem ipsum dolor sit amet consectetur adipiscing elit"
    A -- B
}

A simple graph

如何将图形左对齐,即使A、B和“lorem”的首字母垂直对齐? 属性 labeljustlabelloc 有其他用途,我在 参考 来实现此结果。

By default, Graphviz centers the graph relatively to its caption (label):

graph {
    label="lorem ipsum dolor sit amet consectetur adipiscing elit"
    A -- B
}

A simple graph

How can I align the graph to the left, i.e., make A, B and the initial of "lorem" vertically aligned?
The attributes labeljust and labelloc have other purposes, and I cannot see anything in the reference to achieve this result.

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

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

发布评论

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

评论(1

望喜 2025-01-24 04:16:52

(它有助于将您的源代码包含为文本,而不是 png)
没有直接的方法,但是(如果需要)使用不可见节点和/或节点宽度来使图形足够宽以满足您的需求。然后使用 labeljust 属性将标签对齐到整个图表的左侧(或右侧)。

graph {
  //  does not seem to work  size="8!"
  label="abcdefghijklmnopqrstuvblahblah" labeljust=r
  {rank=same a  node[style=invis width="2."] x1 x2 edge[style=invis] x1--a--x2}
  a--b
} 

给予:
输入图片此处描述

(it helps it include your source as text, not png)
No direct way, but (if needed) use invisible nodes and/or node width to get the graph wide enough to meet your needs. Then use the labeljust attribute to to justify the label to the left (or right) of the entire graph.

graph {
  //  does not seem to work  size="8!"
  label="abcdefghijklmnopqrstuvblahblah" labeljust=r
  {rank=same a  node[style=invis width="2."] x1 x2 edge[style=invis] x1--a--x2}
  a--b
} 

giving:
enter image description here

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