Graphviz 中相同的节点,不同的颜色

发布于 2024-12-01 23:23:30 字数 375 浏览 0 评论 0原文

我在 Graphviz 中有一个简单的有向图,有两种节点和边。每种都有自己的颜色。我的问题是,我想保留图表的绘制方式,但只需更改颜色。但是,当我交换两个节点定义中的节点名称时,图形会更改其布局。

node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen] 3 "4-5" 7 "8-9" 10 18 19
node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = grey]  11 12 "13-14"

有没有办法强制它采用静态布局?

I have a simple directed graph in Graphviz with two kinds of nodes and edges. Each kind has it's own color. My problem is, that I would like to keep how the graph is drawn, but just change the colors. However, when I swap the node names within the two node definitions, the graph changes its layout.

node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen] 3 "4-5" 7 "8-9" 10 18 19
node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = grey]  11 12 "13-14"

Is there a way to force it to one static layout?

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

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

发布评论

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

评论(1

俏︾媚 2024-12-08 23:23:30

定义节点的顺序确实会对布局产生影响。

如果您想保留布局并仅更改节点的颜色,那么您需要保持节点(第一个)外观的顺序,并且仅更改其填充颜色代码>属性。

例如:

digraph g {
  node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen];
  3;
  "4-5";
  7;
  "8-9";
  10 [fillcolor = grey];
  18;
  19;
  // new default fillcolor
  node [fillcolor = grey];
  11;
  12 [fillcolor = palegreen];
  "13-14";
}

生成

fillcolor Nodes

您可以使用 节点指定默认属性 [fillcolor = grey] 指令,并在需要时覆盖特定节点上的默认值 (12 [fillcolor = fadegreen])。

The order in which the nodes are defined does have an impact on the layout.

If you want to keep the layout and change only the colors of the nodes, then you'll need to keep the order of (first) appearance of the nodes and only change their fillcolor attribute.

For example:

digraph g {
  node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen];
  3;
  "4-5";
  7;
  "8-9";
  10 [fillcolor = grey];
  18;
  19;
  // new default fillcolor
  node [fillcolor = grey];
  11;
  12 [fillcolor = palegreen];
  "13-14";
}

Resulting in

fillcolor nodes

You can specify the default attributes using the node [fillcolor = grey] instruction, and override the default values on a specific node if needed (12 [fillcolor = palegreen]).

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