[R] bwplot [lattice]: how to get different y-axis scales for each row?
Marius Hofert
m_hofert at web.de
Sat Mar 26 09:34:24 CET 2011
Dear expeRts,
How can I get ...
(1) different y-axis scales for each row
(2) while having the same y-axis scales for different columns?
I coulnd't manage to do this with relation="free" [which gives (1) but not (2)].
I also tried relation="sliced", but it did not give the same y-axis scales
within each row (see the fourth row). Further, it "separates" the panels.
Cheers,
Marius
## minimal example:
library(lattice)
## build example data set
dim <- c(100, 6, 2, 3) # n, groups, methods, attributes
dimnames <- list(n=paste("n=", seq_len(100), sep=""),
groups=paste("group=", seq_len(6), sep=""),
methods=paste("method=", seq_len(2), sep=""),
attr=paste("attribute=", seq_len(3), sep=""))
set.seed(1)
data <- rexp(prod(dim))
arr <- array(data=data, dim=dim, dimnames=dimnames)
arr[,2,,] <- arr[,2,,]*10
arr[,4,2,2] <- arr[,4,2,2]*10
z <- abs(sweep(arr, 3, 1))
df <- as.data.frame.table(z, responseName="error")
## box plot
bwplot(error ~ methods | attr * groups, data=df,
as.table=TRUE, notch=TRUE,
scales=list(alternating=c(1,1), tck=c(1,0)))
## with relation="sliced"
bwplot(error ~ methods | attr * groups, data=df,
as.table=TRUE, notch=TRUE,
scales=list(alternating=c(1,1), tck=c(1,0), relation="sliced"))
More information about the R-help
mailing list