2013-10-17 89 views
0

我無法讓GraphViz尊重某些節點位置,即使它們具有!pos屬性。例如: -GraphViz忽略我的節點位置

digraph Versions { 
    ranksep=0.05; 
    node [style=filled, shape=point, fillcolor=black, fixedsize=true, width=0.3, height=0.1, fontname="Helvetica", fontsize=8, fontcolor=white]; 
    edge [arrowhead=none, len=0.1]; 
    2 [pos="0,0!", fillcolor=red]; 
    3 [pos="20,0!", fillcolor=red]; 
    4 [pos="40,0!", fillcolor=red]; 
    5 [pos="60,0!", fillcolor=red]; 
    6 [pos="80,0!", fillcolor=red]; 
    7 [pos="100,0!", fillcolor=red]; 
    8 [pos="120,0!", fillcolor=red]; 
    9 [pos="140,0!", fillcolor=red]; 
    10 [pos="160,0!", fillcolor=red]; 
    11 [pos="180,0!", fillcolor=red]; 
    12 [pos="200,0!", fillcolor=red]; 
    13 [pos="220,0!", fillcolor=red]; 
    2 -> 14; 
    14 -> 15; 
    3 -> 16; 
    16 -> 17; 
    11 -> 18; 
    18 -> 19; 
    6 -> 20; 
    20 -> 21; 
    10 -> 22; 
    22 -> 23; 
    13 -> 24; 
    24 -> 25; 
    9 -> 26; 
    26 -> 27; 
    4 -> 28; 
    28 -> 29; 
    7 -> 30; 
    30 -> 31; 
    5 -> 32; 
    32 -> 33; 
    8 -> 34; 
    34 -> 35; 
    12 -> 36; 
    36 -> 37; 
    15 -> 38; 
    38 -> 39; 
    17 -> 40; 
    40 -> 41; 
    19 -> 42; 
    42 -> 43; 
    // etc. 
} 

最上面的等級應分佈均勻,但。最頂部的節點之間的水平間距是不一樣的:

enter image description here

回答

1

pos屬性的文檔:

在NEATO和FDP,POS可以用來設置初始位置的節點。

您使用NEATOFDP因爲不尊重這個屬性。


假設你正在使用NEATO,這裏是從manual的摘錄:

-n [1 | 2](無操作)如果設置,NEATO假設節點已經定位和所有節點都有一個POS屬性賦予位置

這意味着你可以渲染的圖形與

neato -n2 -Tpng mygraph.gv -o mygraph.png 

並且具有neato尊重節點的pos屬性(以點爲單位)。

這也表示全部節點必須具有pos屬性。

由於圖的某些節點沒有pos屬性,這會導致錯誤。

+0

謝謝,我沒有使用neato。雖然在我的情況下不能獨立約束x/y。 [我寫了我自己的佈局](http://stackoverflow.com/questions/19424665/graphviz-fixing-only-the-y-position-of-nodes/19451579#19451579) –