How to plot multiple interactive plots in one window using R?

260 Views Asked by At

I use iplot (GCR more precisely) to draw multiple interactive bar charts and scatter diagrams for my analysis. However, for each execution, the windows must be arranged manually (may exist an automatic way too that I am not aware of).

So, I am wondering if there is a way to put couple of them in one large window. I know that it is possible to give window size and position. However, they will have multiple windows that are irritating.

Thanks

1

There are 1 best solutions below

0
On

I'm not aware of a way to combine two plots in one. However, you could be using iplot.location() and iplot.size, as you already mentioned:

library(iplots)
iPlotsRestore <- function(setting) { 
  invisible(lapply(1:length(iplot.list()), function(x) {
    iplot.location(x = setting[[x]]['x'], y = setting[[x]]['y'], plot = iplot.list()[[x]])
    iplot.size(width = setting[[x]]['width'], height = setting[[x]]['height'], plot = iplot.list()[[x]])
  }))
}

iplotsStore <- function() {
  setting <- lapply(iplot.list(), function(x) iplot.location(plot = x))
  return(setting)
}


setting <- list(structure(c(542, 527, 432, 416), .Names = c("x", "y", "width", "height")), structure(c(10, 0, 432, 416), .Names = c("x", "y", "width", "height")), structure(c(885, 0, 873, 609), .Names = c("x",  "y", "width", "height")))
invisible(lapply(iplot.list(), iplot.off)) # delete all plots
ihist(iris$Sepal.Width) # recreate three demo plots
ihist(iris$Petal.Length)
ihist(iris$Sepal.Width)
iPlotsRestore(setting) # recreate old window settings

Use IplotsStore to get a list of window parameters for all current plots, which you may save to a file. Use iPlotsRestore to restore the window parameters again.