[R] Adding lines to xyplot with abline

David Winsemius dwinsemius at comcast.net
Thu Aug 19 17:06:29 CEST 2010


On Aug 19, 2010, at 10:31 AM, <Jeffrey.Morris at sanofipasteur.com> wrote:

> Is it kosher to add, say, horizontal lines to a lattice xyplot using
> abline(h=xxx)?  The lines don't appear at the right value, that is, if
> h=150, the line might appear at h=140?

Correct. The coordinate systems are not shared between lattice and  
base graphics.

?panel.abline

If you have an existing plot on your screen device, you can try what  
the help pages describe as an experimental method:

trellis.focus("panel", 1, 1)
    panel.abline(h=140)
  trellis.unfocus()

As far as I can tell, it doesn't actually change the lattice object  
but the plot can be saved as whatever options for "Save as" your GUI  
may offer.
-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list