grid                package:graphics                R Documentation

_A_d_d _G_r_i_d _t_o _a _P_l_o_t

_D_e_s_c_r_i_p_t_i_o_n:

     'grid' adds an 'nx' by 'ny' rectangular grid to an existing plot.

_U_s_a_g_e:

     grid(nx = NULL, ny = nx, col = "lightgray", lty = "dotted",
          lwd = NULL, equilogs = TRUE)

_A_r_g_u_m_e_n_t_s:

   nx,ny: number of cells of the grid in x and y direction.  When
          'NULL', as per default, the grid aligns with the tick marks
          on the corresponding _default_ axis (i.e., tickmarks as
          computed by 'axTicks').  When 'NA', no grid lines are drawn
          in the corresponding direction.

     col: character or (integer) numeric; color of the grid lines.

     lty: character or (integer) numeric; line type of the grid lines.

     lwd: non-negative numeric giving line width of the grid lines;
          defaults to 'par("lwd")'.

equilogs: logical, only used when _log_ coordinates and alignment with
          the axis tick marks are active.  Setting 'equilogs = FALSE'
          in that case gives _non equidistant_ tick aligned grid lines.

_N_o_t_e:

     If more fine tuning is required, use 'abline(h = ., v = .)'
     directly.

_S_e_e _A_l_s_o:

     'plot', 'abline', 'lines', 'points'.

_E_x_a_m_p_l_e_s:

     plot(1:3)
     grid(NA, 5, lwd = 2) # grid only in y-direction

     ## maybe change the desired number of tick marks:  par(lab=c(mx,my,7))
     op <- par(mfcol = 1:2)
     with(iris,
          {
          plot(Sepal.Length, Sepal.Width, col = as.integer(Species),
               xlim = c(4, 8), ylim = c(2, 4.5), panel.first = grid(),
               main = "with(iris,  plot(...., panel.first = grid(), ..) )")
          plot(Sepal.Length, Sepal.Width, col = as.integer(Species),
               panel.first = grid(3, lty=1,lwd=2),
               main = "... panel.first = grid(3, lty=1,lwd=2), ..")
          }
         )
     par(op)

