Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot list of plots in GGiraph

Tags:

r

ggplot2

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?

like image 378
Anders Eriksson Avatar asked Sep 15 '25 07:09

Anders Eriksson


1 Answers

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))
like image 98
Ryan SY Kwan Avatar answered Sep 16 '25 20:09

Ryan SY Kwan