graphviz - 如何在直箭头上创建标签
graphviz - how to create labels over straight arrows
也许我比我应该更努力地弯曲 graphviz,但是它会吗
可以拉直箭头吗?我需要标签在箭头上方,而不是像 label/xlabel 那样在旁边;我使用盒子来保存本质上是标签文本的内容,因为在标签很长的时候在边缘使用标签似乎会导致古怪的行为。
digraph G {
node [shape=rect style=filled
fontcolor=white fontsize=12 fontname="Helvetica Bold"]
edge [style=solid color="#777777"]
// introduce nodes; set fill
a1, a2, a3 [fillcolor="#438dd5"]
c1 [fillcolor="#08427b"]
b1, b2, b3 [fillcolor=white fontcolor=black fontname="Helvetica" shape=plain]
a1 -> b1[dir=none]
a2 -> b2[dir=none]
a3 -> b3[dir=none]
b1 -> c1
b2 -> c1
b3 -> c1
{ rankdir=LR rank=same a1 a2 a3 }
{ rankdir=LR rank=same b1 b2 b3 }
{ rankdir=LR rank=same c1 }
}
我得到的:
我想要的:
我通常使用 tables with no borders and white background instead of labels. You would probably also need to use headlabel
or taillabel
, because in this case you can precisely control their position with labeldistance
and labelangle
:
digraph G {
node [shape=rect style=filled
fontcolor=white fontsize=12 fontname="Helvetica Bold"]
graph [ranksep=1]
edge [style=solid color="#777777"]
a1 [fillcolor="#438dd5"]
a2 [fillcolor="#438dd5"]
a3 [fillcolor="#438dd5"]
c1 [fillcolor="#08427b"]
a1 -> c1 [
labeldistance=5
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b1</td>
</tr>
</table>
>
]
a2 -> c1 [
labeldistance=4
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b2</td>
</tr>
</table>
>
]
a3 -> c1 [
labeldistance=5
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b3</td>
</tr>
</table>
>
]
}
结果:
也许我比我应该更努力地弯曲 graphviz,但是它会吗 可以拉直箭头吗?我需要标签在箭头上方,而不是像 label/xlabel 那样在旁边;我使用盒子来保存本质上是标签文本的内容,因为在标签很长的时候在边缘使用标签似乎会导致古怪的行为。
digraph G {
node [shape=rect style=filled
fontcolor=white fontsize=12 fontname="Helvetica Bold"]
edge [style=solid color="#777777"]
// introduce nodes; set fill
a1, a2, a3 [fillcolor="#438dd5"]
c1 [fillcolor="#08427b"]
b1, b2, b3 [fillcolor=white fontcolor=black fontname="Helvetica" shape=plain]
a1 -> b1[dir=none]
a2 -> b2[dir=none]
a3 -> b3[dir=none]
b1 -> c1
b2 -> c1
b3 -> c1
{ rankdir=LR rank=same a1 a2 a3 }
{ rankdir=LR rank=same b1 b2 b3 }
{ rankdir=LR rank=same c1 }
}
我得到的:
我想要的:
我通常使用 tables with no borders and white background instead of labels. You would probably also need to use headlabel
or taillabel
, because in this case you can precisely control their position with labeldistance
and labelangle
:
digraph G {
node [shape=rect style=filled
fontcolor=white fontsize=12 fontname="Helvetica Bold"]
graph [ranksep=1]
edge [style=solid color="#777777"]
a1 [fillcolor="#438dd5"]
a2 [fillcolor="#438dd5"]
a3 [fillcolor="#438dd5"]
c1 [fillcolor="#08427b"]
a1 -> c1 [
labeldistance=5
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b1</td>
</tr>
</table>
>
]
a2 -> c1 [
labeldistance=4
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b2</td>
</tr>
</table>
>
]
a3 -> c1 [
labeldistance=5
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b3</td>
</tr>
</table>
>
]
}
结果: