Tuesday, June 11, 2013

Adding Gridlines in R Manually using abline()

  # vertical grid lines
  xMin <- 0
  xMax <- 10
  xStep <- 1
  for (x in seq(xMin, xMax, xStep)){
   print (x)
   abline(v=(seq(x,100,25)), col=195, lty="dotted")
  }
  # highlight on x=4 and x=5
  abline(v=(seq(4,100,25)), col="red", lty=1)
  abline(v=(seq(5,100,25)), col="red", lty=1)

  # horizontal grid lines
  yMin <- 0
  yMax <- 1
  yStep <- 0.1
  for (y in seq(yMin, yMax, yStep) ){
   print (y)
   abline(h=(seq(y,100,25)), col=195, lty="dotted")
  }

  # highlight at y=0.8
  abline(h=(seq(0.8,100,25)), col="red", lty=1)

No comments:

Post a Comment