[R] drawing axes on all 4 sides of a trellis plot

Steven Lacey slacey at umich.edu
Tue Nov 14 17:16:28 CET 2006


Hi, 

I am creating a 4 x 8 trellis plot. I want the y axis scaled by the data in
the rows, and the x axis scaled by data in each column. In March 2006 there
was a post describing a way to do this. The link is:

tolstoy.newcastle.edu.au/R/help/06/03/22937.html

I am using the data from the example provided in the earlier post and have
modified the plotting code to meet my needs (see below). The problem with
the result is that the x and y axes only appear on the left and bottom of
the plot. I would like them to appear on the left/bottom and top/right.
However, the workaround to produce the plot requires setting relation to
"free", which causes xyplot to ignore the alternating argument.

Any suggestions on how to do this would be greatly appreciated. 

Thanks, 
Steve

d <- expand.grid(a = gl(4, 1, 20), b = gl(8, 1, 40))
d$x <- with(d, rnorm(nrow(d), mean = as.numeric(a) + as.numeric(b)))
d$y <- with(d, rnorm(nrow(d), mean = as.numeric(a) + as.numeric(b)))
xyplot(y ~ x | a + b, d, 
       scales =
       list(y =
            list(relation = "free",
                 limits =
rep(c(rep(list(c(0,100)),4),rep(list(c(0,10)),4)),4),
                 at = rep(list(TRUE, NULL, NULL, NULL),8)),
            x =
            list(relation = "free",
                 limits = rep(list(c(0, 11), c(1, 12), c(2, 13), c(4, 14)),
8),
                 at = rep(list(NULL, TRUE),c(28,4)),
                 labels = c(rep(list(NULL),28),rep(list(TRUE, NULL),2)))),
       par.settings =
       list(layout.heights = list(axis.panel = rep(c(0, 1), c(7, 1))),
            layout.widths = list(axis.panel = rep(c(1, 0), c(1, 3)))),
       par.strip.text = list(cex = 0.5),
       as.table=TRUE)



More information about the R-help mailing list