简体   繁体   English

更改图形的大小(宽度和高度)(GraphViz&dot)

[英]Change Size (Width and Height) of Graph (GraphViz & dot)

Often, the default layout of graphs drawn by GraphViz in the dot language is a little "tight." 通常,GraphViz以点语言绘制的图形的默认布局有点“紧”。 With too little visual space, it's hard to put meaningful labels on edges and the graph can look cluttered. 由于视觉空间太小,很难在边缘上放置有意义的标签,图形看起来很杂乱。

How do I affect the vertical and horizontal spacing of GraphViz / dot graphs? 如何影响GraphViz /点图的垂直和水平间距?

DEFAULT 默认

I will start with a simple graph that is laid out by the dot engine in the default manner: 我将从一个简单的图表开始,由点引擎以默认方式布局:

digraph {
node [shape=circle, width=0.4];
A->B
A->D
B->C
D->E 
}

在此输入图像描述

CHANGING HEIGHT 改变高度

As you can see, the layout is quite tight. 如您所见,布局非常紧凑。 Notice that my ranks (rows) naturally go from top to bottom. 请注意,我的排名(行)自然是从上到下。 I can affect the height of the graph by exploiting this and using the ranksep (rank separation) variable to explicitly set the space between the ranks: 我可以通过利用这个并使用ranksep (rank separation)变量来明确设置排名之间的空间来影响图的高度

digraph { 
node [shape=circle, width=0.4];
ranksep = 1;
A->B
A->D
B->C
D->E 
}

在此输入图像描述

CHANGING WIDTH 改变宽度

Finally, we may want to widen the diagram. 最后,我们可能想要扩大图表。 Here we use the nodesep variable to increase the space between the nodes (columns): 这里我们使用nodesep变量来增加节点(列)之间的空间:

digraph { 
node [shape=circle, width=0.4];
nodesep=1.5;
A->B
A->D
B->C
D->E 
}

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM