[R] Y-axis label on the right hand side in lattice?

Saptarshi saptarshi.guha at gmail.com
Fri Mar 16 23:01:27 CET 2012


ylab.right is perfect. However, I am drawing scales on the right axis
(outside) (see code 1).
When ylab.right is set to something it overlaps with the scale labels.

see http://imgur.com/Gs3JS

I seem to have asked the question:
http://tolstoy.newcastle.edu.au/R/e5/help/08/09/1887.html

But the same thing appears to happen. Is there a padding option for the
right hand side label?

Code:

axis.PCT<-
    function(side, ...) 
{
    ylim <- current.panel.limits()$ylim
    print(panel.number())
    switch(side,
           left = {
               prettyF <- pretty(ylim)
               panel.axis(side = side, outside = TRUE,text.cex=0.5,rot=0,
                          at = prettyF, labels = prettyF)
           },
           right = {
             prettyF <- pretty(ylim)
             yat = round(scaleTo(prettyF, scaler[[panel.number()+1]]),2) ##
this wont work!!!! scalar is my own list.
             panel.axis(side = side, outside = TRUE,text.cex=0.5,rot=0,
                        at = prettyF, labels = yat)
           },
           axis.default(side = side, ...))
}     
library(grid)
library(lattice)
u=xyplot(this~buildnum|as.factor(version),data=wsimple2,type=c('p','l'),cex=0.5
  ,pch=16,scales=list(x=list(rot=80,cex=0.45,tick.number=10,relation='free')
            ,y = list(relation='free',tick.number=10,tck=0.5,alternating=3))
  ,ylab=list('Red Line: % Change over Median of Last 3 BuildIDs',cex=0.75)
  ,ylab.right=list('Blue Line: % Change over FF10',cex=0.75)
  ,panel=function(x,y,subscripts,...){
    panel.abline(v=x[back.window],col='black',lty=3)
    panel.abline(h=0,col='black',lty=3)
    panel.loess(x,wsimple2[subscripts,"past"],col='#0000ff40',lwd=2)
    z <- (predict(loess(y~x,span=0.65),x,se=TRUE))
    yup <- z$fit+2.32*z$se.fit
    ylo <- z$fit-2.32*z$se.fit
    yw <- which(y > yup | y < ylo)
    panel.points(x[yw],y[yw],col='#ff000010',cex=0.7,pch=16)
    panel.points(x[yw],y[yw],col='red',cex=0.5,pch=1,lwd=0.1)
    panel.lines(x,z$fit,col='#ff000040',lwd=4)
    out=sprintf("Outlier Pct=%s",round(length(yw)/length(y)*100),2)
   
grid.text(out,x=unit(0,"npc"),y=unit(0.05,"npc"),just=c("left","bottom"),gp=gpar(cex=0.75))
  }
  ,axis=axis.PCT
  ,main=VNAME
  ,layout=c(1,2),subset=as.numeric(version)>10)


data set: http://people.mozilla.com/~sguha/tmp/tmpa.txt



--
View this message in context: http://r.789695.n4.nabble.com/Y-axis-label-on-the-right-hand-side-in-lattice-tp4478959p4479481.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list