\HeaderA{lines}{Add Connected Line Segments to a Plot}{lines}
\methaliasA{lines.default}{lines}{lines.default}
\keyword{aplot}{lines}
\begin{Description}\relax
A generic function taking coordinates given in various ways and
joining the corresponding points with line segments.
\end{Description}
\begin{Usage}
\begin{verbatim}
lines(x, ...)

## Default S3 method:
lines(x, y = NULL, type = "l", ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, y}] coordinate vectors of points to join.
\item[\code{type}] character indicating the type of plotting; actually any of
the \code{type}s as in \code{\LinkA{plot.default}{plot.default}}.
\item[\code{...}] Further graphical parameters (see \code{\LinkA{par}{par}}) may
also be supplied as arguments, particularly, line type, \code{lty},
line width, \code{lwd}, color, \code{col} and for \code{type = "b"},
\code{pch}.  Also the line characteristics \code{lend}, \code{ljoin}
and \code{lmitre}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The coordinates can be passed to \code{lines} in a plotting structure
(a list with \code{x} and \code{y} components), a time series,
etc. See \code{\LinkA{xy.coords}{xy.coords}}.

The coordinates can contain \code{NA} values. If a point contains
\code{NA} in either its \code{x} or \code{y} value, it is omitted from
the plot, and lines are not drawn to or from such points.  Thus
missing values can be used to achieve breaks in lines.

For \code{type = "h"}, \code{col} can be a vector and will be recycled
as needed.

\code{lwd} can be a vector: its first element will apply to lines but
the whole vector to symbols (recycled as 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{points}{points}}, particularly for \code{type \%in\% c("p","b","o")},
\code{\LinkA{plot}{plot}},
and the workhorse function \code{\LinkA{plot.xy}{plot.xy}}.

\code{\LinkA{abline}{abline}} for drawing (single) straight lines.

\code{\LinkA{par}{par}} for how to specify colors.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# draw a smooth line through a scatter plot
plot(cars, main="Stopping Distance versus Speed")
lines(lowess(cars))
\end{ExampleCode}
\end{Examples}

