私はgraphvizを使用していますが、ノード「This on top」をページの上部に強制し、横に配置するのは好きではありません。これはグラフです:
これはコードです:
g= Digraph('trial', filename='trial.gv')
g.attr(compound='true', rankdir="TB" )
with g.subgraph() as s:
s.attr(rank='max')
s.node('This on top ')
s.edge('this right under', "Fabrication")
with g.subgraph(name='cluster0') as c:
c.node("This")
c.node("that")
c.node("and this on the same level")
g.edge("this right under","that", lhead="cluster0" )
g.edge("that","This on top ", ltail="cluster0" )
g
ノードが希望するTOP / Bottomの順序で表示されることを確認するコマンドはありますか?
最初の問題は、設定rank='max'
により、最初のサブグラフのすべてが最低ランクである最大ランクに移動するように強制されることです。rank='min'
サブグラフ内のアイテムを最高ランクに配置するように設定するつもりだったかもしれませんが、それでも希望する配置は作成されません。
代わりに、style = 'invis'
エッジを作成するときに「これを上に」を「この真下」の前に強制的に設定することで、非表示のエッジを使用できます。
from graphviz import Digraph
g= Digraph('trial', filename='trial.gv')
g.attr(compound='true', rankdir="TB" )
with g.subgraph() as s:
# s.attr(rank='min') # you don't need this line
s.node('This on top ')
s.edge('This on top ', 'this right under', style='invis') # add this invisible edge
s.edge('this right under', "Fabrication")
with g.subgraph(name='cluster0') as c:
c.node("This")
c.node("that")
c.node("and this on the same level")
g.edge("this right under", "that", lhead="cluster0" )
g.edge("that", "This on top ", ltail="cluster0", constraint="false" )
g
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加