[R] Lattice: useOuterStrips and axes

Peter Ehlers ehlers at ucalgary.ca
Tue Mar 1 21:27:13 CET 2011


On 2011-03-01 10:29, Jim Price wrote:
> Consider the following:
>
>
> library(lattice)
> library(latticeExtra)
>
> temp<- expand.grid(
> 		    subject = factor(paste('Subject', 1:3)),
> 		    var = factor(paste('Variable', 1:3)),
> 		    time = 1:10
> 		    )
> temp$resp<- rnorm(nrow(temp), 10 * as.numeric(temp$var), 1)
>
> ylimits<- by(temp$resp, temp$var, function(x) range(pretty(x)))
>
> useOuterStrips(xyplot(
> 		      resp ~ time | subject * var,
> 		      data = temp,
> 		      as.table = TRUE,
> 		      scales = list(
> 				    alternating = 1, tck = c(1, 0),
> 				    y = list(relation = 'free', rot = 0, limits = rep(ylimits, each =
> 3))
> 				    )
> 		      ))
>
>
> This is a matrix of variables on subjects, where it makes sense to have
> panel-specific y-axes because of the differing variable ranges. In fact, it
> makes sense to have row-specific y-axes, because of the similarity of
> intra-variable inter-subject response. However the graphic as presented
> gives per-panel y-axis annotation - I'd like to drop the 2nd and 3rd columns
> of y-axes labels, so the panels become a contiguous array.
>
> Is this possible?

Looks like you want the combineLimits() function in latticeExtra.
Specifically,

  p <- [your code]
  combineLimits(p, margin.y = 1, extend = FALSE)

Peter Ehlers

>
> Thanks,
> Jim Price.
> Cardiome Pharma. Corp.
>
>
>



More information about the R-help mailing list