Re: [R] add horizontal line "(ABLINE(V=))" to xyplot lattice

From: <>
Date: Tue, 13 May 2008 13:02:24 +0100

> In a lattice plot like this:
> win.graph()
> xyplot(tmx~frequ|as.factor(as.numeric(spf)),groups=as.factor(blm),
> data=tmx,type="l",pch=16,xlab="frequency (N)",ylab="Area held (ha)",
> auto.key=list(blm,points=F,lines=T,title="Blm factor",cex.title=0.7,
> cex=0.7,corner=c(1,1)),main="Mangroves target=1573ha",layout=c(2,3))
> I would like to add a horizontal line to each one of the 5 graphs
> with a single value, v=1573

Try using a custom panel function, something like:

mypanelfn <- function(x,y,...)
  panel.xyplot(x=x, y=y, ...)
  grid.lines(c(0,1), unit(rep(1573, 2), "native") }
xyplot(<your params>, panel=mypanelfn)

You can also try using llines instead of grid.lines.


Mathematical Sciences Unit

ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 13 May 2008 - 12:03:50 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 Tue 13 May 2008 - 12:30:41 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive