更改布局图

时间:2019-06-25 09:11:48

标签: r graphviz 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}

}


      ") 

1 个答案:

答案 0 :(得分:1)

如果要在节点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']

给你

enter image description here