Learn R Programming

Boom (version 0.8)

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, ...)

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

Value

Called for its side effect.

See Also

boxplot.true

Examples

Run this code
# NOT RUN {
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