我正在尝试绘制一个包含3个节点级别的图表,这些级别之间的距离相等。 然而,graphviz以某种方式决定中间水平和底部水平之间的距离应远大于顶部和中间水平之间的距离。有什么方法可以解决这个问题吗?
这是我的代码:
digraph g{
rankdir="LR";
graph [pad="0.5", ranksep="0.525", nodesep="3"];
splines=false;
node[shape = square];
edge[style=invis];
subgraph cluster_3 {
color=invis;
a1->a2->a3->a4->a5->a6->a7;
}
subgraph cluster_2 {
color=invis;
a->b->c->d->e->f->g;
}
subgraph cluster_1 {
color=invis;
1->2->3->4->5->6->7;
}
"a1" [label="1'"];
"a2" [label="2'"];
"a3" [label="3'"];
"a4" [label="4'"];
"a5" [label="5'"];
"a6" [label="6'"];
"a7" [label="7'"];
edge[style=solid, constraint=false];
a->1[arrowhead=none, arrowtail=none];
a->2[arrowhead=none, arrowtail=none];
a->3[arrowhead=none, arrowtail=none];
a->a1[arrowhead=none, arrowtail=none];
a->a2[arrowhead=none, arrowtail=none];
a->a3[arrowhead=none, arrowtail=none];
b->1[arrowhead=none, arrowtail=none];
b->3[arrowhead=none, arrowtail=none];
b->7[arrowhead=none, arrowtail=none];
b->a1[arrowhead=none, arrowtail=none];
b->a3[arrowhead=none, arrowtail=none];
b->a7[arrowhead=none, arrowtail=none];
c->2[arrowhead=none, arrowtail=none];
c->6[arrowhead=none, arrowtail=none];
c->7[arrowhead=none, arrowtail=none];
c->a2[arrowhead=none, arrowtail=none];
c->a6[arrowhead=none, arrowtail=none];
c->a7[arrowhead=none, arrowtail=none];
d->1[arrowhead=none, arrowtail=none];
d->4[arrowhead=none, arrowtail=none];
d->7[arrowhead=none, arrowtail=none];
d->a1[arrowhead=none, arrowtail=none];
d->a4[arrowhead=none, arrowtail=none];
d->a7[arrowhead=none, arrowtail=none];
e->1[arrowhead=none, arrowtail=none];
e->2[arrowhead=none, arrowtail=none];
e->3[arrowhead=none, arrowtail=none];
e->a1[arrowhead=none, arrowtail=none];
e->a2[arrowhead=none, arrowtail=none];
e->a3[arrowhead=none, arrowtail=none];
f->1[arrowhead=none, arrowtail=none];
f->4[arrowhead=none, arrowtail=none];
f->7[arrowhead=none, arrowtail=none];
f->a1[arrowhead=none, arrowtail=none];
f->a4[arrowhead=none, arrowtail=none];
f->a7[arrowhead=none, arrowtail=none];
g->5[arrowhead=none, arrowtail=none];
g->6[arrowhead=none, arrowtail=none];
g->7[arrowhead=none, arrowtail=none];
g->a5[arrowhead=none, arrowtail=none];
g->a6[arrowhead=none, arrowtail=none];
g->a7[arrowhead=none, arrowtail=none];
}
目前的输出如下:
答案 0 :(得分:18)
只是玩了一下并想出下面的图表,这是否更接近想要?
digraph g{
graph [pad="0.5", nodesep="1", ranksep="2"];
splines="false";
node[shape = square];
edge[style=invis];
a1->a->1
a2->b->2
a3->c->3
a4->d->4
a5->e->5
a6->f->6
a7->g->7
"a1" [label="1'"];
"a2" [label="2'"];
"a3" [label="3'"];
"a4" [label="4'"];
"a5" [label="5'"];
"a6" [label="6'"];
"a7" [label="7'"];
edge[style=solid, constraint=false];
a->1[arrowhead=none, arrowtail=none];
a->2[arrowhead=none, arrowtail=none];
a->3[arrowhead=none, arrowtail=none];
a->a1[arrowhead=none, arrowtail=none];
a->a2[arrowhead=none, arrowtail=none];
a->a3[arrowhead=none, arrowtail=none];
b->1[arrowhead=none, arrowtail=none];
b->3[arrowhead=none, arrowtail=none];
b->7[arrowhead=none, arrowtail=none];
b->a1[arrowhead=none, arrowtail=none];
b->a3[arrowhead=none, arrowtail=none];
b->a7[arrowhead=none, arrowtail=none];
c->2[arrowhead=none, arrowtail=none];
c->6[arrowhead=none, arrowtail=none];
c->7[arrowhead=none, arrowtail=none];
c->a2[arrowhead=none, arrowtail=none];
c->a6[arrowhead=none, arrowtail=none];
c->a7[arrowhead=none, arrowtail=none];
d->1[arrowhead=none, arrowtail=none];
d->4[arrowhead=none, arrowtail=none];
d->7[arrowhead=none, arrowtail=none];
d->a1[arrowhead=none, arrowtail=none];
d->a4[arrowhead=none, arrowtail=none];
d->a7[arrowhead=none, arrowtail=none];
e->1[arrowhead=none, arrowtail=none];
e->2[arrowhead=none, arrowtail=none];
e->3[arrowhead=none, arrowtail=none];
e->a1[arrowhead=none, arrowtail=none];
e->a2[arrowhead=none, arrowtail=none];
e->a3[arrowhead=none, arrowtail=none];
f->1[arrowhead=none, arrowtail=none];
f->4[arrowhead=none, arrowtail=none];
f->7[arrowhead=none, arrowtail=none];
f->a1[arrowhead=none, arrowtail=none];
f->a4[arrowhead=none, arrowtail=none];
f->a7[arrowhead=none, arrowtail=none];
g->5[arrowhead=none, arrowtail=none];
g->6[arrowhead=none, arrowtail=none];
g->7[arrowhead=none, arrowtail=none];
g->a5[arrowhead=none, arrowtail=none];
g->a6[arrowhead=none, arrowtail=none];
g->a7[arrowhead=none, arrowtail=none];
}
答案 1 :(得分:0)
要添加到@uncletall答案(并部分解决@ ingomueller.net问题),看来nodeep和ranksep在如何分离节点方面有很大的影响:
http://www.graphviz.org/doc/info/attrs.html#d:nodesep
nodesep:双精度,默认值:0.25,最小值:0.02 指定同一节点中两个相邻节点之间的最小间距 排名,以英寸为单位。
对于其他布局,nodesep会影响节点上循环之间的间距 单节点或一对节点之间的多边。
对以下图形有效:
http://martin-loetzsch.de/S-DOT/ranksep.html
给出所需的等级间隔,以英寸为单位。这是最低的 一排节点的底部与节点之间的垂直距离 节点的顶部。