如何使用R在一个窗口中绘制多个交互式图?

时间:2015-07-21 08:00:34

标签: r plot iplots

我使用 iplot (更准确地说是GCR)为我的分析绘制多个交互式条形图和散点图。但是,对于每次执行,必须手动安排窗口(可能存在我不知道的自动方式)。

所以,我想知道是否有办法将其中几个放在一个大窗口中。我知道可以给出窗口大小和位置。但是,他们会有多个令人烦恼的窗户。

由于

1 个答案:

答案 0 :(得分:0)

我不知道将两个情节合二为一的方法。但是,您可能正在使用iplot.location()iplot.size,如您所述:

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

使用IplotsStore获取所有当前图表的窗口参数列表,您可以将其保存到文件中。使用iPlotsRestore再次恢复窗口参数。