\HeaderA{segments}{Add Line Segments to a Plot}{segments}
\keyword{aplot}{segments}
\begin{Description}\relax
Draw line segments between pairs of points.
\end{Description}
\begin{Usage}
\begin{verbatim}
segments(x0, y0, x1, y1,
         col = par("fg"), lty = par("lty"), lwd = par("lwd"),
         ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x0, y0}] coordinates of points \bold{from} which to draw.
\item[\code{x1, y1}] coordinates of points \bold{to} which to draw.
\item[\code{col, lty, lwd}] usual graphical parameters as in
\code{\LinkA{par}{par}}, possibly vectors.  \code{NA} values in \code{col}
cause the segment to be omitted.
\item[\code{...}] further graphical parameters (from \code{\LinkA{par}{par}}),
such as \code{xpd} and the line characteristics \code{lend}, \code{ljoin}
and \code{lmitre}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For each \code{i}, a line segment is drawn between the point
\code{(x0[i], y0[i])} and the point \code{(x1[i], y1[i])}.  The
coordinate vectors will be recycled to the length of the longest.

The graphical parameters \code{col}, \code{lty} and \code{lwd} can be
vectors of length greater than one and will be recycled if necessary.
\end{Details}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{arrows}{arrows}}, 
\code{\LinkA{polygon}{polygon}} for slightly easier and less flexible line
drawing, and
\code{\LinkA{lines}{lines}} for the usual polygons.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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')
\end{ExampleCode}
\end{Examples}

