2013-11-02 48 views
1

考慮以下晶格例之間線的寬度:調整板

library(lattice) 
x <- c(1:10, 1:10) 
y <- c(10:1, 10:1) 
z <- c(1:10, seq(1,20, by=2)) 
a = c(rep("one",10),rep("two",10)) 

DF <- data.frame(x, y, z, a) 

xyplot(y ~ x | a, groups = z < 5, data = DF, col = c("black", "red"), 
pch=20, cex=0.3) 

我的問題是:如何能夠增加垂直線 分離板的tickness?

回答

2

你可以玩這樣的事情。我使用面板函數向左或右的每個面板添加一個段,具體取決於調節變量。

xyplot(y ~ x | a, groups = z < 5, data = DF, col = c("black", "red"), 
     pch=20, cex=0.3, 
     panel = function(...,subscripts){ 
     limits <- current.panel.limits() 
     xx <- limits$xlim 
     yy <- limits$ylim 
     if(unique(print(DF[subscripts,'a']))=="two"){ 
      lsegments(xx[1], yy[1], xx[1], yy[2],lwd=20) 
     }else{ 
      lsegments(xx[2], yy[1], xx[2], yy[2],lwd=20) 
     } 

     panel.xyplot(...,subscripts=subscripts) 
     }) 

enter image description here