首页 > 解决方案 > Graphviz:垂直对齐子图

问题描述

我有四个子图,我想(a)具有相同的宽度并且(b)垂直对齐(红色>黄色>绿色>紫色)。我不知道该怎么做。这是dot代码,为清楚起见进行了简化:

digraph {
    rankdir = "TB";
    compound=true;
    node [shape=box, style=filled,color=white];
    subgraph cluster_pre_proto_greek {
        label="Pre-Proto-Greek";
        style=filled;
        color=red;
        c1 [label = "1. Change of word-final *ms to *ns"];
        c2 [label = "2. Loss of word-final *i̯ after a long vowel"];
        c3 [label = "3. Change of dental stop to *s before dental stop"];
    }
    subgraph cluster_pre_proto_attic_ionic {
        label="Pre-Proto-Attic-Ionic";
        style=filled;
        color=yellow;
        c4 [label = "4. Merger of *K̑ with *K"];
        c5 [label = "5. Merger of *Ku̯ and *Kʷ"];
        c6 [label = "6. Loss of laryngeals"];
    }
    subgraph cluster_pre_homeric {
        label="Pre-Homeric";
        style=filled;
        color=green;
        c7 [label = "7. Early vowel contractions and rise of tones"];
        c8 [label = "8. Metathesis of *TK to *KT"];
        c9 [label = "9. Vowel epenthesis before word-initial *r"];
    }
    subgraph cluster_homeric {
        label="Homeric";
        style=filled;
        color=purple;
        c10 [label = "10. Devoicing of voiced aspirates"];
        c11 [label = "11. Vocalisation of syllabic sonorants before vowel or *i̯"];
        c12 [label = "12. Vocalisation of syllabic nasals"];
    }

    c1 -> c12;
    c3 -> c6;
    c3 -> c9;
    c4 -> c5;
    c5 -> c11;
    c6 -> c7;
    c6 -> c11;
    c6 -> c12;
    c7 -> c8;
    c9 -> c10;
    c10 -> c11;
    c10 -> c12;
    c11 -> c12;
}

这是输出(来自edotor.net):

Graphviz 图表(更新)

任何帮助是极大的赞赏!

编辑:这是我想要得到的:

Graphviz 图表:修改

标签: widthvertical-alignmentgraphvizsubgraph

解决方案


我相信问题的出现是因为它试图最小化垂直高度,解决这个问题的一种方法是传递minlen=2到一些边缘,所以尝试:

c1 -> c12
c3 -> c6;
c3 -> c9;
c4 -> c5;
c5 -> c11;
c6 -> c7 [minlen=2];
c6 -> c11;
c6 -> c12;
c7 -> c8;
c9 -> c10 [minlen=2];
c10 -> c11;
c10 -> c12;
c11 -> c12;

您还可以尝试注释掉各种边缘以查看它们对最终图像的影响,constraint=false如果要删除它的影响,您可以添加。


推荐阅读