[R] Lattice : Single reference line/label at 0.05
Deepayan Sarkar
deepayan.sarkar at gmail.com
Mon Jun 30 21:35:40 CEST 2008
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
More information about the R-help
mailing list