【问题标题】:Changing layout DiagrammeR更改布局 DiagrammeR
【发布时间】:2019-11-07 02:02:11
【问题描述】:

我正在尝试使用 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}

}


      ") 

【问题讨论】:

    标签: r graphviz diagrammer


    【解决方案1】:

    如果你想在节点B之上有节点A,你必须指向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']
    

    给你

    【讨论】:

    • 很好的答案。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-10
    • 2013-08-24
    相关资源
    最近更新 更多