How do I draw gridlines using abline() that are behind the data?

前端 未结 4 1605
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 06:57

When I draw grid lines on a plot using abline() the grid lines are drawn over the data.

Is there a way to draw the abline() lines behind

4条回答
  •  悲&欢浪女
    2020-12-05 07:17

    The panel.first argument of plot() can take a list or vector of functions so you can put your abline() calls in there.

    plot(1:4, panel.first = 
           c(abline(h = 1:4, lty = 2, col = 'grey') 
            ,abline(v = 1:4, lty = 2, col = 'grey')))
    

提交回复
热议问题