Draw grid lines on specific values in xyplot

前端 未结 3 2229
傲寒
傲寒 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条回答
  •  感动是毒
    2021-02-10 05:12

    According to lattice changelog:

    Changes in lattice 0.19
    =======================

    o Added new arguments 'grid' and 'abline' in panel.xyplot().

    So you could do it in one line:

    require(lattice)
    X <- data.frame(xx=runif(20), yy=rnorm(20))
    
    xyplot(yy~xx, X, abline=list(h=0))
    

    Lattice graph with added line

    If you want panel.grid like line style, then nice trick:

    xyplot(yy~xx, X, abline=c(list(h=0),trellis.par.get("reference.line")))
    

    Lattice graph with added nice style line

提交回复
热议问题