[R] Adding text to strip in xYplot

John Poulsen jpoulsen at zoo.ufl.edu
Wed Apr 9 14:39:09 CEST 2008


Hello again,

I have been trying to add an expression to the strips in xYplot to no 
avail.  For example, in the code below, the text in the strips for each 
panel is "Anls" and "Plts".  However, I would like it to add "Anls km^2" 
and "Plants km^2" with the exponents raised.

I tried resetting the name of my groups in the dataframe before 
plotting, but the dataframe only recognized the entire expression (e.g. 
expression(paste("Anls", km^2,sep=" ")) and not Anls km2 - which should 
not have surprised me.

Any ideas?  Thanks for any help you can provide.

John

x1=rseq(1,30,0.5)
y1=x1^2
y2=10*(x1^2)
ycomb=c(y1,y2)
y.up=ycomb+0.1*ycomb
y.low=ycomb-0.1*ycomb
grp=rep(c("Anls","Plts"),each=length(x1)))
dat=as.data.frame(cbind(ycomb, y.up, y.low, rep(x1,2)),stringsAsFactors=F)
colnames(dat)=c("ycomb","y.up","y.low","x1")

with(dat,xYplot(Cbind(ycomb, y.up, y.low)~x1|factor(grp), 
data=dat,type="l", method="bands", scales=list(y=list(relation="free"),
        x=list(alternating=c(1,1,1))),ylim=list(c(0,1200),c(0,10000))))



More information about the R-help mailing list