I have a function that returns an arrangeGrob
. I would like the access the individual ggplot objects to make them an input to say ggplotly. I tried looking at the structure of the arrangeGrob object, but there doesn't seem that there is a way to get that. I don't need to plot the plot I need to use it elsewhere. In the example below, I'd like to be able to get back each of the (ggplot) p1 in the list given to arrangeGrob.
library(ggplot2)
library(gridExtra)
p1 = ggplot(data = pressure, aes(x = temperature, y = pressure)) + geom_line() + theme_light()
p = arrangeGrob(grobs = list(p1, p1), ncol=2, widths=c(1,1))
str(p)
grid.draw(p)
grid.draw(p$grobs[[1]])
grid.draw(p$grobs[[2]])
str(p1)
str(p$grobs[[2]])
plot(p$grobs[[2]])
library(plotly)
ggplotly(p$grobs[[2]])