0

我目前正在尝试使用 DiagrammeR 创建流程图

library(DiagrammeR)
grViz("
digraph g { 
subgraph cluster_0 {
style=filled;
color=lightgrey;
label= To_Accrue
node [shape = rectangle, style = filled, fillcolor = Linen]
A
B
C
A->B->C
}
subgraph cluster_1 {
style=filled;
color=crimson;
label= Y
node [style=filled,color=blue, shape=folder]
1
2
3
1->2->3
}
}
")

请参阅链接文件以查看它当前生成的内容(Tab-Sheet1)。我想知道是否有办法实现所需的输出(Tab-Desired Output)。

先感谢您。

4

2 回答 2

0

我还编辑了原始代码以生成以下内容来处理旋转场景。 在此处输入图像描述

library(DiagrammeR)

grViz("
digraph g { 
subgraph cluster_0 {
style=filled;
color=lightgrey;
label= To_Accrue
node [shape = rectangle, style = filled, fillcolor = Linen]
a1 [style = invis, shape=point, width = 0, group=g1]
a2 [style = invis, shape=point, width = 0, group=g2]
a3 [style = invis, shape=point, width = 0, group=g3]
A [group=g1]
B
C [group=g1]
C [group=g2]
D
E [group=g2]
edge [arrowhead='none']
A->a1
C->a2
E->a3
edge [arrowhead='normal']
B->a1 {rank=same B a1}
a1->C
D->a2 {rank=same D a2}
a2->E
F->a3 {rank=same F a3}
a3->G
}
subgraph cluster_1 {
style=filled;
color=crimson;
label= Y
node [style=filled,color=blue, shape=folder]
1
2
3
1->2->3
}
}
")
于 2019-04-10T18:38:25.620 回答
0

这里的技巧是使用空白节点(在此称为bnode)、组(g1在此示例中)和排名 ( rank=same ...) 来强制您想要的定位和外观。同组的节点应该出现在同一个垂直平面,同等级的节点会出现在同一个水平平面。

library(DiagrammeR)

grViz("
digraph g { 
subgraph cluster_0 {
style=filled;
color=lightgrey;
label= To_Accrue
node [shape = rectangle, style = filled, fillcolor = Linen]
bnode [style = invis, shape=point, width = 0, group=g1]
A [group=g1]
B
C [group=g1]
edge [arrowhead='none']
A->bnode
edge [arrowhead='normal']
B->bnode
bnode->C
{rank=same B bnode}
}
subgraph cluster_1 {
style=filled;
color=crimson;
label= Y
node [style=filled,color=blue, shape=folder]
1
2
3
1->2->3
}
}
")
于 2019-04-10T17:19:37.383 回答