2012-11-13 32 views
0

是否有一种平台无关的方式来排列屏幕输出的格子图?trellis.device的平台无关版本(device =“windows”,...)

我的方法包括使用:

trellis.device(device="windows") 
print(chart.hist, split = c(1,1,1,2), more = TRUE) 
print(chart.cdf, split = c(1,2,1,2)) 

在我的Mac,我需要trellis.device(device="x11",...),我的Windows机器在工作中我需要trellis.device(device="windows",...)

一个例子:

set.seed(1) 
x <- rnorm(100, 0, 1) 

discrete.cdf <- function(x, decreasing=FALSE){ 
    x <- x[order(x,decreasing=FALSE)] 
    result <- data.frame(rank=1:length(x),x=x) 
    result$cdf <- result$rank/nrow(result) 
    return(result) 
} 

my.df <- discrete.cdf(x) 

chart.hist <- histogram(~x, data=my.df, 
         xlab="") 
chart.cdf <- xyplot(100*cdf~x, data=my.df, type="s", 
        ylab="Cumulative Percent of Total") 

graphics.off() 
trellis.device(device = "windows", width = 6, height = 6) 
print(chart.hist, split = c(1,1,1,2), more = TRUE) 
print(chart.cdf, split = c(1,2,1,2)) 

回答

2

只是省略了选项“设备”到trellis.device()功能。它将采用特定于平台的默认设置(至少它在Linux上的工作方式与“x11”是默认设备)。

+0

似乎在Windows上工作 – mac