Re: [R] Lattice : Single reference line/label at 0.05

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Mon, 30 Jun 2008 12:35:40 -0700

On 6/30/08, Troy S <troysocks-twigs_at_yahoo.com> wrote:
> r-friends--
>
> I am trying to make a lattice plot with a single label at 0.05. A reference line at y=0.05 as well... This is what I have so far. The label reads 0.0 and there is a grid instead of a single reference line. Can someone help please?
>
> Troy
> x<-18:35
> (pv<-1/(x-17))
> xydf<-data.frame(x, pv)
> print(xyplot(pv~x, data=xydf, type=c('p', 'g'),
> ylim=c(0,1),
> yscale.components= function(lim, ...) {
> ans <- yscale.components.default(lim = lim, ...)
> ans$left$ticks$at <- c(0.05)
> ans$left$ticks$labels$at <- c(0.05)
> ans$left$ticks$labels$labels <- c("0.05")
> ans
> }
>
> ))

You probably meant to do

print(xyplot(pv~x, data=xydf, type=c('p', 'g'),  ylim=c(0,1),
 yscale.components= function(lim, ...) {    ans <- yscale.components.default(lim = lim, ...)

   ans$left$ticks$at <- c(0.05)
   ans$left$labels$at <- c(0.05)
   ans$left$labels$labels <- c("0.05")

   ans
   }
 ))

but this is simpler:

xyplot(pv~x, data=xydf, type=c('p', 'g'), ylim = c(0, 1),

         scales = list(y = list(at = 0.05)),
         panel = function(...) {
             panel.abline(h = 0.05)
             panel.xyplot(...)
         })

-Deepayan



R-help_at_r-project.org 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. Received on Mon 30 Jun 2008 - 19:39:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 30 Jun 2008 - 20:33:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive