Grid line consistent with ticks on axis

后端 未结 4 1033
悲&欢浪女
悲&欢浪女 2020-12-13 14:38

I am embarrassed to ask this simple question, but has been in kicking my mind for several days whenever I create a plot:

plot (x = 1:10, y = rnorm (10, 5, 2)         


        
4条回答
  •  离开以前
    2020-12-13 14:55

    For posterity, here is the long-winded way of doing it manually:

    plot (x = 1:10, y = rnorm (10, 5, 2))
    grid (lty = 6, col = "cornsilk2")
    
    xaxp <- par("xaxp")
    yaxp <- par("yaxp")
    
    abline(v=seq(xaxp[1], xaxp[2], (xaxp[2]-xaxp[1])/xaxp[3]), lty=6, col = "cornsilk2")
    abline(h=seq(yaxp[1], yaxp[2], (yaxp[2]-yaxp[1])/yaxp[3]), lty=6, col = "cornsilk2")
    

提交回复
热议问题