segments              package:graphics              R Documentation

_A_d_d _L_i_n_e _S_e_g_m_e_n_t_s _t_o _a _P_l_o_t

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

     Draw line segments between pairs of points.

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

     segments(x0, y0, x1, y1,
              col = par("fg"), lty = par("lty"), lwd = par("lwd"),
              ...)

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

  x0, y0: coordinates of points *from* which to draw.

  x1, y1: coordinates of points *to* which to draw.

col, lty, lwd: usual graphical parameters as in 'par', possibly
          vectors.  'NA' values in 'col' cause the segment to be
          omitted.

     ...: further graphical parameters (from 'par'), such as 'xpd' and
          the line characteristics 'lend', 'ljoin' and 'lmitre'.

_D_e_t_a_i_l_s:

     For each 'i', a line segment is drawn between the point '(x0[i],
     y0[i])' and the point '(x1[i], y1[i])'.  The coordinate vectors
     will be recycled to the length of the longest.

     The graphical parameters 'col', 'lty' and 'lwd' can be vectors of
     length greater than one and will be recycled if necessary.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

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

     'arrows',  'polygon' for slightly easier and less flexible line
     drawing, and 'lines' for the usual polygons.

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

     x <- stats::runif(12); y <- stats::rnorm(12)
     i <- order(x,y); x <- x[i]; y <- y[i]
     plot(x, y, main="arrows(.) and segments(.)")
     ## draw arrows from point to point :
     s <- seq(length(x)-1)# one shorter than data
     arrows(x[s], y[s], x[s+1], y[s+1], col= 1:3)
     s <- s[-length(s)]
     segments(x[s], y[s], x[s+2], y[s+2], col= 'pink')

