[R] Control of axis limits in multiple panel lattice plots

Peter Davenport pwdavenport at gmail.com
Wed Oct 27 10:28:37 CEST 2010


Unwanted space (padding?) is introduced at the extremes of the x and y
axes of my lattice plots.
I've tried defining the scales using xlim, scale and num.limits in
x.scale.components, but haven't succeded in getting overriding the
introduction of extra space.
Here's the problem:

test.df<-data.frame(a=runif(100,0,1),b=c(runif(50,0,1),runif(50,0,2)),c=c(rep(c("A","B"),c(50,50))))

1) Space appears when I plot multiple panels:
        xyplot(a~b|c,data=test.df)

2) I can get rid of the space by explicitly defining scales (shown for
x axis)...
        xyplot(a~b|c,data=test.df
              ,scale=list(x=list(limits=c(0,2),at=seq(0,2,0.5)))
	      )

3) ...but not when relation="free":
        xyplot(a~b|c,data=test.df
              ,scale=list(x=list(relation="free",limits=list(c(0,1),c(0,2)),at=seq(0,2,0.5)))
	      )

Peter Davenport



More information about the R-help mailing list