lines {graphics} | R Documentation |

## Add Connected Line Segments to a Plot

### Description

A generic function taking coordinates given in various ways and
joining the corresponding points with line segments.

### Usage

lines(x, ...)
## Default S3 method:
lines(x, y = NULL, type = "l", col = par("col"),
lty = par("lty"), ...)

### Arguments

`x, y` |
coordinate vectors of points to join. |

`type` |
character indicating the type of plotting; actually any of
the `type` s as in `plot` . |

`col` |
color to use. This can be vector of length greater than
one, but only the first value will be used. |

`lty` |
line type to use. |

`...` |
Further graphical parameters (see `par` ) may
also be supplied as arguments, particularly, line type, `lty` and
line width, `lwd` . |

### Details

The coordinates can be passed to `lines`

in a plotting structure
(a list with `x`

and `y`

components), a time series,
etc. See `xy.coords`

.

The coordinates can contain `NA`

values. If a point contains
`NA`

in either its `x`

or `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 `type = "h"`

, `col`

can be a vector and will be recycled
as needed.

### References

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

### See Also

`points`

, particularly for `type %in% c("p","b","o")`

,
`plot`

,
and the underlying “primitive” `plot.xy`

.

`par`

for how to specify colors.

### Examples

# draw a smooth line through a scatter plot
plot(cars, main="Stopping Distance versus Speed")
lines(lowess(cars))

[Package

*graphics* version 2.1.0

Index]