[BioC] lattice and base-graphics using gridBase
Maarten van Iterson
M.van_iterson.HG at lumc.nl
Tue May 11 09:34:58 CEST 2010
Dear list,
I'm trying to combine lattice and base-graphics following the example
from Paul Murrell's R Graphics (B.1.2).
The question I have is how to add the y-axis from the base-graphics to
the lattice plot below?
library(gridBase)
library(lattice)
data <- list(A=matrix(rnorm(8*100, 1, 1), ncol=8), B=matrix(rnorm(8*100,
0, 1), ncol=8), C=matrix(rnorm(8*100, -1, 1), ncol=8))
boxplot.panel <- function(x, y, subscripts, ...){
pushViewport(viewport(gp=gpar(fontsize=8)),
viewport(y=unit(0.95, "npc"), width=0.9,
height=unit(0.95, "npc"), just="top"))
par(plt=gridPLT(), new=TRUE, ps=8)
boxplot(data[[subscripts]], col=rep(2:7, each=2), ylab="", axes=FALSE,
names=NULL, outline=FALSE)
popViewport(2)
}
df <- data.frame(y=1:3, x=1:3, Method=LETTERS[1:3])
xyplot(y ~ x | Method, data=df, subscripts=TRUE, xlab="", ylab="",
panel=boxplot.panel, layout=c(1,3))
sessionInfo()
R version 2.10.0 (2009-10-26)
x86_64-unknown-linux-gnu
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets
methods
[8] base
other attached packages:
[1] lattice_0.17-26 gridBase_0.4-3
Thanks in advance,
Maarten
--
Maarten van Iterson
Center for Human and Clinical Genetics
Leiden University Medical Center (LUMC)
Research Building, Einthovenweg 20
Room S-04-038
Phone: 071-526 9439
E-mail: M.van_iterson.HG at lumc.nl
---------------
Postal address:
Postzone S-04-P
Postbus 9600
2300 RC Leiden
The Netherlands
More information about the Bioconductor
mailing list