gpt4 book ai didi

graphviz - 使用graphviz强制边缘上的方角

转载 作者:行者123 更新时间:2023-12-04 01:12:35 24 4
gpt4 key购买 nike

我有以下 .dot文件。

digraph
{
node [color=Limegreen,fontcolor=Limegreen,shape=oval]
ilocus [label="iLocus"]
gilocus [label="giLocus"]
pilocus [label="piLocus"]
nilocus [label="niLocus"]
silocus [label="siLocus"]
cilocus [label="ciLocus"]
filocus [label="fiLocus"]
iilocus [label="iiLocus"]

node [color=Blue,fontcolor=Blue,shape=diamond]
containgene [label="Contains gene(s)?"]
proteincoding [label="Protein coding?"]
multiplegenes [label="Multiple genes?"]
geneflank [label="Flanked by genes\non both sides?"]

ilocus -> containgene
containgene:e -> geneflank [xlabel="No"]
geneflank:e -> filocus [xlabel="No"]
geneflank:w -> iilocus [xlabel="Yes"]
containgene:w -> gilocus [xlabel="Yes"]
gilocus -> proteincoding
proteincoding:e -> nilocus [xlabel="No"]
proteincoding:w -> pilocus [xlabel="Yes"]
pilocus -> multiplegenes
multiplegenes:e -> silocus [xlabel="No"]
multiplegenes:w -> cilocus [xlabel="Yes"]
}

使用 graphviz 渲染我得到以下信息。

Graphviz take 1

有什么办法可以强制边缘有方角而不是圆角? splines=ortho文档中的属性原则上似乎是为此而设计的,但实际上,当我添加 graph [splines=ortho] 时,我只会得到直线。到我的有向图。

Graphviz take 2

有什么办法可以用graphviz在边缘上得到方角?类似于以下内容:
  ------ Multiple genes? -----
| |
| N Y |
| |
v V
siLocus ciLocus

最佳答案

也许你可以从 splines=line 开始

digraph
{
splines=line
...

这会给你这个图:

Graph using splines=line

从那里您可能需要手动定位节点,或插入隐藏的节点和边,如
digraph
{
splines=line

node [color=Limegreen,fontcolor=Limegreen,shape=oval]
ilocus [label="iLocus"]
gilocus [label="giLocus"]
pilocus [label="piLocus"]
nilocus [label="niLocus"]
silocus [label="siLocus"]
cilocus [label="ciLocus"]
filocus [label="fiLocus"]
iilocus [label="iiLocus"]

node [color=Blue,fontcolor=Blue,shape=diamond]
containgene [label="Contains gene(s)?"]
proteincoding [label="Protein coding?"]
multiplegenes [label="Multiple genes?"]
geneflank [label="Flanked by genes\non both sides?"]

spacer1 [label="xxxx",style=invis]
{rank=same gilocus spacer1 geneflank}
gilocus -> spacer1 -> geneflank [style=invis]

ilocus -> containgene
containgene:e -> geneflank [xlabel="No"]
geneflank:e -> filocus [xlabel="No"]
geneflank:w -> iilocus [xlabel="Yes"]
containgene:w -> gilocus [xlabel="Yes"]
gilocus -> proteincoding
proteincoding:e -> nilocus [xlabel="No"]
proteincoding:w -> pilocus [xlabel="Yes"]
pilocus -> multiplegenes
multiplegenes:e -> silocus [xlabel="No"]
multiplegenes:w -> cilocus [xlabel="Yes"]
}

产生

enter image description here

或者,您可以在顶部标签中插入空格以使较低的节点更好地排列:
digraph
{
splines=line

node [color=Limegreen,fontcolor=Limegreen,shape=oval]
ilocus [label="iLocus"]
gilocus [label="giLocus"]
pilocus [label="piLocus"]
nilocus [label="niLocus"]
silocus [label="siLocus"]
cilocus [label="ciLocus"]
filocus [label="fiLocus"]
iilocus [label="iiLocus"]

node [color=Blue,fontcolor=Blue,shape=diamond]
containgene [label=" Contains gene(s)? "]
proteincoding [label="Protein coding?"]
multiplegenes [label="Multiple genes?"]
geneflank [label="Flanked by genes\non both sides?"]

ilocus -> containgene
containgene:e -> geneflank [xlabel="No"]
geneflank:e -> filocus [xlabel="No"]
geneflank:w -> iilocus [xlabel="Yes"]
containgene:w -> gilocus [xlabel="Yes"]
gilocus -> proteincoding
proteincoding:e -> nilocus [xlabel="No"]
proteincoding:w -> pilocus [xlabel="Yes"]
pilocus -> multiplegenes
multiplegenes:e -> silocus [xlabel="No"]
multiplegenes:w -> cilocus [xlabel="Yes"]
}

产生

enter image description here

关于graphviz - 使用graphviz强制边缘上的方角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35007701/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com