There is a lattice llines function that replaces the function of lines() functionality in base. There is also a panel.lines function.
#---------- method --------------
xyplot(-1:1 ~ -1:1, type="l")
trellis.focus("panel", 1, 1)
do.call("panel.abline", list(h=0,v=0, lty=3) )
trellis.unfocus()
# --- that method has the advantage of also demonstrating
# how to modify an existing plot
#---------- method 2--------------
xp <-xyplot(-2:1 ~ -2:1, type="l", panel=function(...){
panel.xyplot(...)
panel.abline(h=0,v=0, lty=3)} )
xp
There is a lattice llines function that replaces the function of lines() functionality in base. There is also a panel.lines function.
According to lattice changelog:
So you could do it in one line:
If you want
panel.grid
like line style, then nice trick:If you're using package
lattice
(which is implied withxyplot
), you can usepanel.abline
to draw lines over labeled ticks.