最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

r - Specify two different rankdir for node branching at end - Stack Overflow

programmeradmin0浏览0评论

How to get nodes a2 and a3 to fall vertically in line with a1 without having to specify node width and height?

library(DiagrammeR)
grViz("
 digraph G {
  
    graph [splines=ortho, nodesep=1, dpi=70]
    rankdir=LR
    
    node [shape=box, fontname=Helvetica];
    {rank=same;
        x1; x3;
        y1 [shape = point, width = 0, height = 0];
    }
    x2[fontsize=20,height=1.5,width=2];
    x4; x5;
    
    x1 [label = 'a0'];
    x2 [label = 'b0'];
    x3 [label = 'a1'];
    x4 [label = 'a2'];
    x5 [label = 'a3'];
    
    x1 -> y1 [arrowhead=none]
    y1 -> x2
    y1 -> x3
    x3 -> {x4, x5}
 
 }
")

Current output:

Desired output (only showing last 3 boxes):

How to get nodes a2 and a3 to fall vertically in line with a1 without having to specify node width and height?

library(DiagrammeR)
grViz("
 digraph G {
  
    graph [splines=ortho, nodesep=1, dpi=70]
    rankdir=LR
    
    node [shape=box, fontname=Helvetica];
    {rank=same;
        x1; x3;
        y1 [shape = point, width = 0, height = 0];
    }
    x2[fontsize=20,height=1.5,width=2];
    x4; x5;
    
    x1 [label = 'a0'];
    x2 [label = 'b0'];
    x3 [label = 'a1'];
    x4 [label = 'a2'];
    x5 [label = 'a3'];
    
    x1 -> y1 [arrowhead=none]
    y1 -> x2
    y1 -> x3
    x3 -> {x4, x5}
 
 }
")

Current output:

Desired output (only showing last 3 boxes):

Share Improve this question edited Jan 30 at 1:28 SRL asked Jan 29 at 19:19 SRLSRL 1872 silver badges10 bronze badges 2
  • regardless of how much text is contained within a2 and a3? - Nope, not realistically with dot – sroush Commented Jan 29 at 23:17
  • @sroush edited to remove that constraint – SRL Commented Jan 30 at 1:28
Add a comment  | 

1 Answer 1

Reset to default 1

Flipped back to default rankdir and associated changes.
All-in-all dot may not be the best tool for your needs. pikchr (https://pikchr./home/doc/trunk/homepage.md) might work better.

 digraph G {
  
    graph [ splines=ortho,  nodesep=1, dpi=70]
   // rankdir=LR
    
    node [shape=box, fontname=Helvetica];
   // {rank=same;
        x1; x3;
        y1 [shape = point, width = 0, height = 0 ]
   // }
    
    x1 [label = "a0"];
    x2 [label = "b0" fontsize=20,height=1.5,width=2]
    x3 [label = "a1"];
    // x2[fontsize=20,height=1.5,width=2];
    x4[label = "a2"];
    x5[label = "a3"];
 
    {rank=same x2 y1}
    {rank=same x4 x5 } 
    x1 -> y1 [arrowhead=none]
    y1 -> x2
    y1 -> x3
    x3 -> x4
    x3 -> x5
}

Giving:

发布评论

评论列表(0)

  1. 暂无评论