Draw grid lines on specific values in xyplot

前端 未结 3 2227
傲寒
傲寒 2021-02-10 04:34

I have a xyplot and I want to draw grid lines on the 0 values.

How this can be done?

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-10 05:02

    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
    

提交回复
热议问题