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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Saptarshi
Hello,

Is there a way to add ylab on the right hand side also (in lattice)?
Different from the left hand side?

Cheers
Saptarshi

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Y-axis label on the right hand side in lattice?

Richard M. Heiberger
from ?xyplot
use the
ylab.right
argument



On Fri, Mar 16, 2012 at 2:11 PM, Saptarshi Guha <[hidden email]>wrote:

> Hello,
>
> Is there a way to add ylab on the right hand side also (in lattice)?
> Different from the left hand side?
>
> Cheers
> Saptarshi
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Y-axis label on the right hand side in lattice?

David Winsemius

On Mar 16, 2012, at 2:53 PM, Richard M. Heiberger wrote:

> from ?xyplot
> use the
> ylab.right
> argument
>

>
> On Fri, Mar 16, 2012 at 2:11 PM, Saptarshi Guha <[hidden email]
> >wrote:
>
>> Hello,
>>
>> Is there a way to add ylab on the right hand side also (in lattice)?
>> Different from the left hand side?


I thought he wanted facilities provided by

doubleYScale in latticExtra package

--

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Y-axis label on the right hand side in lattice?

David Winsemius

On Mar 16, 2012, at 3:03 PM, David Winsemius wrote:

>
> On Mar 16, 2012, at 2:53 PM, Richard M. Heiberger wrote:
>
>> from ?xyplot
>> use the
>> ylab.right
>> argument
>>
>
>>
>> On Fri, Mar 16, 2012 at 2:11 PM, Saptarshi Guha <[hidden email]
>> >wrote:
>>
>>> Hello,
>>>
>>> Is there a way to add ylab on the right hand side also (in lattice)?
>>> Different from the left hand side?
>
>
> I thought he wanted facilities provided by
>
> doubleYScale in latticExtra package
                 ^latticeExtra^

> --
>


David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Y-axis label on the right hand side in lattice?

Saptarshi
In reply to this post by David Winsemius
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

Reply | Threaded
Open this post in threaded view
|

Re: Y-axis label on the right hand side in lattice?

Richard M. Heiberger
yes,

xyplot(y ~ x, par.settings=list(layout.widths=list(ylab.right=5,
right.padding=0)))

See trellis.par.get("layout.widths")
for the full set of names and default values



On Fri, Mar 16, 2012 at 6:01 PM, Saptarshi <[hidden email]> wrote:

> 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.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Y-axis label on the right hand side in lattice?

Saptarshi
Thanks much.