2013-08-24 21 views
2

有繪製多個圖形的非常方便的方式,這就是與gridExtra - grid.arrange多個格子樣地gridExtra

​​

上面的命令繪製的3x3圖在一個窗口。

現在,我用我自己的格子設置通過

trellis.par.set(my.setup) 

畫獨特的線條等,但使用grid.arrange命令繪製多條曲線不會將設置爲輸出圖是默認的顏色。

所以現在的問題是如何在my.setup轉嫁給grid.arrange或可選擇地如何在一氣呵成的格子輕鬆繪製多個圖形。

編輯:重複的例子:

Data <- data.frame(Col1=rnorm(10,0,1),Col2=rexp(10,2),Col3=rnorm(10,2,2),Col4=runif(10,0,2), 
     Time=seq(1,10,1)) 

trellis.par.set(col.whitebg()) 
newSet <- col.whitebg() 
newSet$superpose.symbol$col <- c("blue3","orange2","gray1","tomato3") 
newSet$superpose.symbol$pch <- 1 
newSet$superpose.symbol$cex <- 1 
newSet$superpose.line$col <- c("blue3","orange2","gray1","tomato3") 
trellis.par.set(newSet) 

Plot1 <- xyplot(Col1+Col2~Time, Data, type="spline") 
Plot2 <- xyplot(Col2+Col3~Time, Data, type="spline") 
Plot3 <- xyplot(Col1+Col3~Time, Data, type="spline") 
Plot4 <- xyplot(Col3+Col4~Time, Data, type="spline") 

grid.arrange(Plot1,Plot2,Plot3,Plot4, ncol=2) 
+0

構建地塊的環境下'my.setup'是目前的'trellis.par'。 –

+0

@DWin。對不起,你能更具體嗎? – Maximilian

+0

點陣具有內置的功能,可以在一個頁面(甚至是多個頁面)中排列多個圖塊,這可能是一個更好的方法。 '?格::: print.trellis' – baptiste

回答

5

我想這是有事情做,當它包裹在gridExtra::drawDetails.latticeplot.trellis方法沒有找到全球主題設置。我不明白,這些格子的選擇,但據我記得你可以在情節層面也明確指定,

pl = list(Plot1, Plot2, Plot3, Plot4) 
# do.call(grid.arrange, c(pl, nrow=1)) 
do.call(grid.arrange, c(lapply(pl, update, par.settings=newSet), list(nrow=1))) 

enter image description here

+0

尼斯,這是它,THX! – Maximilian

+0

Btw。這樣看起來如果我有3個地塊,我想他們水平地而不是垂直?通過上面的例子,提供pl = list(Plot1,Plot2,Plot3),該圖是垂直的(彼此波紋)。謝謝。 – Maximilian

+0

但是這不會使用我當前的設置newSet,這些線條是默認的顏色。 – Maximilian