How to add abline with lattice xyplot function?

后端 未结 1 655
你的背包
你的背包 2020-12-16 19:49

I am trying to plot two variables: Eeff vs Neff using xyplot function of lattice package. I would like to know how to add an line to this scatter plot (which is abline funct

相关标签:
1条回答
  • 2020-12-16 20:16

    The lattice package has several "panel functions", one of which is panel.abline.

    Try this and see if it gives you what you're looking for:

    xyplot(Neff ~ Eeff, data = phuong,
           panel = function(x, y) {
             panel.xyplot(x, y)
             panel.abline(lm(y ~ x))
           }, 
           xlab = "Energy efficiency (%)", 
           ylab = "Nitrogen efficiency (%)")
    
    0 讨论(0)
提交回复
热议问题