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

前端 未结 1 1619
-上瘾入骨i
-上瘾入骨i 2020-12-10 14:36

Often, the default layout of graphs drawn by GraphViz in the dot language is a little \"tight.\" With too little visual space, it\'s hard to put meaningful labels on edges a

相关标签:
1条回答
  • 2020-12-10 15:10

    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:

    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):

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

    0 讨论(0)
提交回复
热议问题