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

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Tue May 13 14:02:24 CEST 2008


> 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.

Regards,
Richie.

Mathematical Sciences Unit
HSL



------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list