\Header{arrows}{Add Arrows to a Plot}
\alias{segments}{arrows}
\keyword{aplot}{arrows}
\begin{Usage}
\begin{verbatim}
arrows(x0, y0, x1, y1, length = 0.25, angle = 30, code = 2,
       col = par("fg"), lty = NULL, xpd = FALSE)
segments(x0, y0, x1, y1,
       col = par("fg"), lty = par("lty"), xpd = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x0,y0}] coordinates of points \bold{from} which to draw.
\item[\texttt{x1,y1}] coordinates of points \bold{to} which to draw.
\item[\texttt{length}] length of the edges of the arrow head (in inches).
\item[\texttt{angle}] angle from the shaft of the arrow to the edge of the arrow head.
\item[\texttt{code}] integer code, determining \emph{kind} of arrows to be drawn.
\item[\texttt{col, lty, xpd}] usual graphical parameters as in \texttt{\Link{par}}.
\end{ldescription}
\end{Arguments}
\begin{Description}
\texttt{segments} draws a line segment and
\texttt{arrows} draws an arrow between the point \texttt{(x0[i], y0[i])}
and the point \texttt{(x1[i],y1[i])}.
If \texttt{code=2} an arrowhead is drawn at \texttt{(x0[i],y0[i])} and if
\texttt{code=1} an arrowhead is drawn at \texttt{(x1[i],y1[i])}.  If
\texttt{code=3} a head is drawn at both ends of the arrow.

The graphical parameters \texttt{col} and \texttt{lty} can be used
to specify a color an line texture for the line segments which
make up the segments or arrows (\texttt{col} may be a vector).\end{Description}
\begin{SeeAlso}
\texttt{\Link{polygon}} for slightly easier and less flexible line drawing and
\texttt{\Link{lines}} for the usual polygons.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- runif(12); y <- 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}

