【问题标题】:How to plot multiple interactive plots in one window using R?如何使用 R 在一个窗口中绘制多个交互式绘图?
【发布时间】:2015-10-10 13:47:40
【问题描述】:

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

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

谢谢

【问题讨论】:

    标签: r plot iplots


    【解决方案1】:

    我不知道将两个情节合二为一的方法。但是,您可以使用 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 恢复窗口参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      • 2021-06-16
      • 1970-01-01
      相关资源
      最近更新 更多