[R] xyplot problem

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Tue Sep 23 16:59:10 CEST 2008


> I am trying to produce some panels with dots in an X/Y plane where the 
> diameter of the dots indicates a Z value (like e.g. earthquake maps 
where dot 
> sizes indicate magnitudes and X/Y the location).
> 
> This works fine with xyplot, e.g.:
> 
> xyplot(1:3~1:3,cex=1:3,pch=16)
> 
> However, when I do this with a panel variable, e.g.:
> 
> x<-rep(1:3,5)
> y <- rep(1:3,5)
> sz <- rep(1:5,each=3)
> grp <- factor(rep(1:5,each=3))
> xyplot(y~x | grp , cex=sz)
> 
> then sz in the cex argument is not applied per group as I would expect. 
Same 
> for other arguments like col.
> 
> Is this really the intended behaviour? 
> 
> How can I achieve what I want, i.e., that the cex argument is different 
for 
> the different levels of grp?

Within a panel function, packet.number tells you what the levels of each 
conditioning factor are.  Try something like this:
#x,y,grp as above
mypanelfn <- function(...) panel.xyplot(cex=packet.number(), ...)
xyplot(y~x | grp , panel=mypanelfn)

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list