Search code examples
rlatexvisualization

Flowchart Replication


I found a flowchart/circuit graph online that I'd like to replicate in a program like LaTex, or DiagrammeR.

However, as it stands, I haven't found a visual analogue in any learning materials. I wondered if anyone could direct me to learning materials for implementing this type of graph, please?

Would be appreciated.

enter image description here


Solution

  • I suppose you could just draw it yourself:

    library(ggplot2)
    library(statebins)
    
    df <- data.frame(x = c(0.5, 2, 2, 2, 2, 3.5),
                     y = c(0, 0.2, 0.8, 0, -0.8, 0),
                     labels = c("Shocks", "", "Equilibrium Data",
                                "Behavioral Data", "Theory", "New Equilibrium"),
                     width = c(0.8, 0.9, 0.8, 0.8, 0.8, 0.8),
                     height = c(0.5, 3, 0.5, 0.5, 0.5, 0.5))
    
    ggplot(df, aes(x, y, colour = factor(labels, labels))) +
      statebins:::geom_rrect(aes(xmin = x - width/2, xmax = x + width/2, 
                     ymin = y - height/2, ymax = y + height/2, 
                     fill = factor(labels, labels))) +
      geom_text(aes(label = labels), size = 6) +
      annotate("segment", x = c(0.9, 2.45), xend = c(1.5, 3.05), y = 0, yend = 0,
               arrow = arrow()) +
      annotate("text", label = "CGE Model", x = 2, y = 1.5, size = 6) +
      scale_fill_manual(values = c("#fbe6e6", "#ccccfb", rep("#e6e6fd", 3),
                                   "#fbe6e6"), guide = "none") +
      scale_color_manual(values = c("#ed3833", "#2846f6", rep("#2a46f6", 3),
                                    "#ed3833"), guide = "none") +
      theme_void() +
      coord_fixed(0.6)
    

    enter image description here