Learn R Programming

Boom (version 0.9.15)

add.segments: Function to add horizontal line segments to an existing plot

Description

Adds horizontal line segments to an existing plot. The segments are centered at x with height y. The x values are assumed to be equally spaced, so that diff(x) is a constant 'dx'. The line segments go from x +/- half.width.factor *dx, so if half.width.factor=.5 there will be no gaps between segments. The default is to leave a small gap.

This function was originally used to add reference lines to side-by-side boxplots.

Usage

AddSegments(x, y, half.width.factor = 0.45, ...)

Value

Called for its side effect.

Arguments

x

A numeric vector giving the midpoints of the line segments.

y

A numeric vector of the same length as x giving the vertical position of the line segments

half.width.factor

See 'description' above.

...

graphical parameters controlling the type of lines used in the line segments

Author

Steven L. Scott

See Also

boxplot.true

Examples

Run this code

x <- rnorm(100)
y <- rnorm(100, 1)
boxplot(list(x=x,y=y))
AddSegments(1:2, c(0, 1))  ## add segments to the boxplot

Run the code above in your browser using DataLab