rggplot2ggiraph

Plot list of plots in GGiraph


I am trying to plot a list of plots using GGiraph in Rstudio. The solution to plot multiple plots is either through Cowplot (ggobj = plot_grid(plot1, plot2)) or Patchwork (code = print(plot / plot)). This works if you individually print single plots. However, it looks like it does not accept a list of plots. I want the plots to be arranged in one column with multiple rows.

Does anyone have a solution to this?


Solution

  • You could try the plotlist argument in plot_grid.

    #Using the example from giraffe
    library(ggiraph)
    library(ggplot2)
    
    dataset <- mtcars
    dataset$carname = row.names(mtcars)
    
    gg_point = ggplot( data = dataset,
        mapping = aes(x = wt, y = qsec, color = disp,
        tooltip = carname, data_id = carname) ) +
      geom_point_interactive() + theme_minimal()
    
    #using the plotlist argument
    library(cowplot)
    girafe(ggobj = plot_grid(plotlist=list(gg_point, gg_point), ncol=1))