[英]unable to print the label and outline box of a cluster subgraph in graphviz
I am a newbie to graphviz and the DOT language. 我是graphviz和DOT语言的新手。 I was trying out generating graphs with cluster subgprahs.
我正在尝试使用群集subgprahs生成图。 However, when I have clusters, each with node positions exactly specified in the script, graphviz does not generate the outline boxes or the labels for the clusters!
但是,当我有群集时,每个群集都在脚本中完全指定了节点位置,graphviz不会为群集生成轮廓框或标签! Specifically, if I have the following DOT script:
具体来说,如果我有以下DOT脚本:
digraph G{
subgraph cluster0{
label="Cluster 0"
a->b
}
subgraph cluster1{
label="Cluster 1"
c->d
}
}
then the graph generated is: 那么生成的图形是:
However, with the following DOT script, in which I specify the node positions of the 4 nodes exactly: 但是,在以下DOT脚本中,我在其中精确指定了4个节点的节点位置:
digraph G{
subgraph cluster0{
label = "Cluster 0"
a[pos="10,200"]
b[pos="100,200"]
a->b
}
subgraph cluster1{
label = "Cluster 1"
c[pos="10,100"]
d[pos="100,100"]
c->d
}
}
The graph generated is: 生成的图形为:
Notice that in this case, neither the outline box for the clusters nor the labels for the clusters are printed!! 请注意,在这种情况下,群集的轮廓框和群集的标签都不会打印! In this case, there is a clear demarcation between the 2 clusters as you can see - the clusters don't overlap, so in principle graphviz should not have a problem showing them, am I right?
在这种情况下,您可以看到两个群集之间有明确的界线-群集不重叠,因此从原则上graphviz应该不会出现显示问题,对吗?
How can I tell graphviz to draw the cluster outline boxes and labels no matter what? 无论如何,如何告诉graphviz绘制群集轮廓框和标签? Any help in this will be greatly appreciated!!
任何帮助,将不胜感激!
Thanks! 谢谢!
The dot layout engine doesn't support the pos
attribute. 点布局引擎不支持
pos
属性。
To render a graph with positions of all nodes predefined, you should use neato
or fdp
with the -n
option. 要使用预定义所有节点的位置来呈现图形,应将
neato
或fdp
与-n
选项一起使用。
neato
doesn't support clusters (though it seems it should now ). neato
不支持集群(尽管现在应该支持)。 Fortunately, fdp
does! 幸运的是,
fdp
可以!
Therefore, you may use the following command: 因此,您可以使用以下命令:
dot -Tpdf -Kpdf -n -O filename.dot
or 要么
fdp -Tpdf -n -O filename.dot
Unfortunately, the positions of the nodes relative to the cluster are ok, but clusters still seem to get moved by fdp ( -n
switch didn't make a difference). 不幸的是,节点相对于群集的位置尚可,但是群集似乎仍被fdp移动(
-n
开关没有影响)。
I didn't try with the latest version (I used 2.29.20120504), but if the latest doesn't work neither, this may be a case for a bug report. 我没有尝试使用最新版本(我使用的是2.29.20120504),但是如果最新版本也不起作用,则可能是错误报告的情况。
Btw, since positions are assumed to be in inches, this will create a very large graph. 顺便说一句,由于假定位置以英寸为单位,所以这将创建一个非常大的图形。
Output I get with fdp (with or without -n
switch) - I added size=20
to limit the image size: 我使用fdp获得的输出(带有或不带有
-n
开关)-我添加了size=20
以限制图像大小:
Alternative solution without using pos
: 不使用
pos
替代解决方案:
digraph G{
subgraph cluster0{
label = "Cluster 0"
{rank=same; a->b;}
}
subgraph cluster1{
label = "Cluster 1"
{rank=same; c->d; }
}
a -> c [style=invis];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.