0

How do you produce the following plot using the R function mermaid from the package DiagrammeR?

Function Mapping

EDIT:

Let's just say we drop the labels "Input" and "Output" along with the red circles. The following is a minimal code for a start in R.

DiagrammeR::mermaid("
graph LR
a --> x
b --> y
c --> y
d --> z
classDef firstSet fill:#F8CECC
class a,b,c,d firstSet
")

whose output looks like this:

mermaid-mapping

Specific questions:

  1. How does one make the edges straight and not folded?
  2. How does one include the red circles?
rxs2p0
  • 1
  • 1
  • 1
    Welcome to Stack Overflow! Your question is clear enough, but it's too broad. You're expected to have made an effort and show where you got stuck. `Diagrammer::mermaid` says the input should be "Diagram in mermaid markdown-like language or file (as a connection or file name) containing a diagram specification.". That means you have to figure out how to **compose the diagram yourself** ... – Ben Bolker Aug 12 '22 at 21:02

1 Answers1

0

Try this code below.
It's not perfect (today is the 3rd day that I started learning Mermaid.js) but it has similar elements like your example:

library(DiagrammeR)

grViz("
digraph {
  graph[rankdir = LR, fontsize = 30]
  edge [color = 'blue', penwidth = 3.5]
  node[color = 'white', fontsize = 25]

  subgraph cluster_1 {
        label = 'Input'
        color = 'red'
  node [shape = circle]
  a; b; c; d}
  
  subgraph cluster_2 {
        label = 'Output'
        color = 'red'
  node [shape = circle] 
  x; y; z}


  a -> x
  b -> y
  c -> y
  d -> z
 
}
")

The final outcome looks like this. I may revisit this answer later once I am more proficient.

Grasshopper_NZ
  • 302
  • 1
  • 10