When we create a plot in R and draw gridlines then the gridlines are drawn on the basis of the values provided inside the grid function, therefore, it may or may not match with the Y-axis labels. But it can be done, we just need to set the values inside the grid function to NULL.
Consider the below plot −
x<-rnorm(10,1) y<-rnorm(10,2) plot(x,y) grid(5,5,lty=5)
Creating the plot with gridlines that matches with Y-axis labels −