更改布局 DiagrammeR
Changing layout DiagrammeR
我正在尝试使用 R 和 DiagrammeR 制作 SEM 图。我已经设置了图表,但我试图在图表底部放置一些节点(CSEW、ONS 和 Police)以使其更易于阅读。
这是我目前所掌握的。欢迎任何关于如何将三个圆圈移动到底部的建议。
library(DiagrammeR)
grViz("
digraph MTMM {
subgraph {
node [shape = box, fixedsize = true, width = 1]
rank = same; bike_c; bike_p; bike_o
burg_c; burg_p; burg_o
theft_c; theft_p; theft_o
viol_c; viol_p; viol_o
}
subgraph {
node [shape = circle, fixedsize = true, width = 1]
Bicycle; Burglary; Theft; Violence
}
subgraph {
node [shape = circle, fixedsize = true, width = 1]
CSEW; ONS; Police
}
Bicycle -> {bike_c bike_p bike_o}
Burglary -> {burg_c burg_p burg_o}
Theft -> {theft_c theft_p theft_o}
Violence -> {viol_c viol_p viol_o}
CSEW -> {bike_c burg_c theft_c viol_c} [label = '1']
ONS -> {bike_o burg_o theft_o viol_o} [label = '1']
Police -> {bike_p burg_p theft_p viol_p} [label = '1']
{rank = same; CSEW; ONS; Police}
{rank = same; Bicycle; Burglary; Theft; Violence}
}
")
如果你想让节点A
在节点B
之上,你必须从A -> B
指向,这是graphviz的基本逻辑。如果你想让箭头指向另一个方向,你可以通过告诉 graphviz 来实现:A -> B[ dir = back]
.
在您的情况下,将相关的三行替换为
{bike_c burg_c theft_c viol_c} -> CSEW [dir = back, label = '1']
{bike_o burg_o theft_o viol_o} -> ONS[dir = back, label = '1']
{bike_p burg_p theft_p viol_p} -> Police[dir = back, label = '1']
这给了你
我正在尝试使用 R 和 DiagrammeR 制作 SEM 图。我已经设置了图表,但我试图在图表底部放置一些节点(CSEW、ONS 和 Police)以使其更易于阅读。
这是我目前所掌握的。欢迎任何关于如何将三个圆圈移动到底部的建议。
library(DiagrammeR)
grViz("
digraph MTMM {
subgraph {
node [shape = box, fixedsize = true, width = 1]
rank = same; bike_c; bike_p; bike_o
burg_c; burg_p; burg_o
theft_c; theft_p; theft_o
viol_c; viol_p; viol_o
}
subgraph {
node [shape = circle, fixedsize = true, width = 1]
Bicycle; Burglary; Theft; Violence
}
subgraph {
node [shape = circle, fixedsize = true, width = 1]
CSEW; ONS; Police
}
Bicycle -> {bike_c bike_p bike_o}
Burglary -> {burg_c burg_p burg_o}
Theft -> {theft_c theft_p theft_o}
Violence -> {viol_c viol_p viol_o}
CSEW -> {bike_c burg_c theft_c viol_c} [label = '1']
ONS -> {bike_o burg_o theft_o viol_o} [label = '1']
Police -> {bike_p burg_p theft_p viol_p} [label = '1']
{rank = same; CSEW; ONS; Police}
{rank = same; Bicycle; Burglary; Theft; Violence}
}
")
如果你想让节点A
在节点B
之上,你必须从A -> B
指向,这是graphviz的基本逻辑。如果你想让箭头指向另一个方向,你可以通过告诉 graphviz 来实现:A -> B[ dir = back]
.
在您的情况下,将相关的三行替换为
{bike_c burg_c theft_c viol_c} -> CSEW [dir = back, label = '1']
{bike_o burg_o theft_o viol_o} -> ONS[dir = back, label = '1']
{bike_p burg_p theft_p viol_p} -> Police[dir = back, label = '1']
这给了你