在美人鱼图表中侧向融合箭头

18

如何在R顺序美人鱼图中添加横向融合的箭头?在下面的示例中:

library(DiagrammeR)
mermaid("
graph TB
    A[GE Solution]-->C{1:1}
    B[GA Solution]-->C{1:1} 
    C{1:1}-->D[Stir 10 mins at 500 r/min]
    D[Stir 10 mins at 500 r/min]-->E[Homogenisation at 10000 r/min]
    ")

我该如何制作类似以下内容的东西?

在此输入图片描述

2个回答

14
使用mermaid的一个可能解决方案:
graph LR
   X --- D[ ]:::empty
   Y --- D
   D --> E
   classDef empty width:0px,height:0px;

Mermaid diagram with merging sideway connectors


2
如果你想让它更简洁一些,你也可以写成:X & Y --- D[ ]:::empty --> E - Ivo Merchiers
类 empty 是一个非常好的想法。样式是否也可以适应其他元素的相对位置? - dudung
3
看起来它不再工作了:箭头相遇的地方有一个空白点。 - Velkan
graph LR X & Y --- D( ):::empty D --> E classDef empty width:-1px,height:-1px; 至少在节点上画一个小圆圈 - 这样... 在我看来比空白的地方稍微好看一点。https://gist.github.com/chrismo/deccb12b9220a5ac357f64ceeb6ac54a/93f71466ba41cd395565b2cfe460efac4630be84 - chrismo
2
当我使用classDef empty width:0px,height:0px;时,箭头之间出现了间隙。然而,如果我使用style D width:0;就足够了。文档:节点样式化 - icc97

5

我尝试使用mermaid,但不确定其中是否有相应功能。似乎它旨在成为简单的文档解决方案,而非具备很高灵活性的解决方案。但你可以使用graphViz完成同样的图示:

library(DiagrammeR)

grViz("digraph dot {
    node [shape=rectange];

    d1 [shape=point,width=0.01,height=0.01];
    {'GE Solution', 'GA Solution'}->d1[dir=none];
    d1->'Stir 10 mins at 500 r/min';
    'Stir 10 mins at 500 r/min'->'Homogenisation at 10000 r/min'}")

这里插入图片描述

编辑以回应评论:使用子图并对一个看不见的点(例如此处的d2)和您希望与其在同一水平线上的节点相同(此处为40oC)进行排序。

grViz("digraph dot {
node [shape=rectange];

d1 [shape=point,width=0.01,height=0.01];
d2 [shape=point, width=0.01, height=0.01];
{'GE Solution', 'GA Solution'}->d1[dir=none];
d1->'Stir 10 mins at 500 r/min';
'Stir 10 mins at 500 r/min'->d2[dir=none];
subgraph {
    rank=same;
    d2; '40oC';
}
d2->'40oC'[dir=none];
d2->'Homogenisation at 10000 r/min'}")

enter image description here


谢谢!最初我渴望在Mermaid中找到一个解决方案,因为它感觉更容易编写。不过,关于与箭头斜连的“40oC”旁边的项目,你也知道如何实现吗? - Scientist
1
我在我的答案中添加了一个编辑,回答了你的问题,但解决方案是使用子图。 - august
1
非常好:我认为你可以不使用子图,只需使用{ rank=same; d2 -> '40oC'[dir=none] }; - user20650

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接