我想显示下面的图,除了两个表在同一水平线上。我希望第二个表格显示在第一个表格的右侧,而不是当前的下方。
我拥有的graphviz当前代码是:
digraph G {
node [shape=record, fontname="Arial"];
set1 [label = "{Blue Crosses | B1 | B2 | B3 | B4 }|{ Square |<b1> Left |<b2> Left |<b3> Right | Left }"];
set2 [label = "{Blue Crosses |<b1> B1 |<b2> B2 |<b3> B3 }|{ Coordinates | (1, 1) | (2, 2) | (4, 2) }"];
set1:b1 -> set2:b1;
set1:b2 -> set2:b2;
set1:b3 -> set2:b3;
}
答案 0 :(得分:0)
为了实现您想要的,您需要添加行
{ rank = same; set1 set2 }
创建节点后,在代码中。但是,在这种情况下,您会发现graphviz
感到困惑,无法再识别端口了。因此,无需使用record = shape
,而是需要使用HTML-like labels重新编码图形。对于提供的示例,我已经做到了(顺便说一句,感谢您对代码和期望结果的明确回答):
digraph G
{
node[ shape = none, fontname = "Arial" ];
set1[ label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD>Blue Crosses</TD>
<TD>Square</TD>
</TR>
<TR>
<TD>B1</TD>
<TD PORT="b1">Left</TD>
</TR>
<TR>
<TD>B2</TD>
<TD PORT="b2">Left</TD>
</TR>
<TR>
<TD>Right</TD>
<TD PORT="b3">Right</TD>
</TR>
<TR>
<TD>B4</TD>
<TD>Left</TD>
</TR>
</TABLE>>];
set2[ label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD>Blue Crosses</TD>
<TD>Coordinates</TD>
</TR>
<TR>
<TD PORT="b1">B1</TD>
<TD>(1, 1)</TD>
</TR>
<TR>
<TD PORT="b2">B2</TD>
<TD>(2, 2)</TD>
</TR>
<TR>
<TD PORT="b3">B3</TD>
<TD>(4, 2)</TD>
</TR>
</TABLE>>];
# layout
nodesep = 2; /* increase distance between nodes */
{ rank = same; set1 set2 }
set1:b1 -> set2:b1;
set1:b2 -> set2:b2;
set1:b3 -> set2:b3;
}
收益