Skip to contents

Add a horizontal or vertical line to the current plot

Usage

AddLine(at = NULL, Outer = FALSE, H = TRUE, ...)

Source

The source code of this function was taken from this stackoverflow question.

Arguments

at

Numeric; the relative location of where the line should be plotted. Cannot be NULL.

Outer

Logical; if TRUE, the line is plotted outside of the plotting area. Default is FALSE.

H

Logical; if TRUE (default), a horizontal line is added. If FALSE, a vertical line is added.

...

Additional graphical parameters passed to graphics::abline.

Value

Invisible; the function is called for its side effect of drawing on the current plot.

Examples

# Horizontal line
par(oma = c(1, 1, 1, 1), mar = c(3, 3, 1, 1))
plot(seq_len(100))
AddLine(at = 0.75)
AddLine(at = 0.25, Outer = TRUE, lwd = 2)
AddLine(at = 0.5, Outer = TRUE, lwd = 2, col = "red")


# ---------------------------------------------

# Vertical line
plot(seq_len(100))
AddLine(H = FALSE, at = 0.75)
AddLine(H = FALSE, at = 0.25, Outer = TRUE, lwd = 2)
AddLine(H = FALSE, at = 0.5, Outer = TRUE, lwd = 2, col = "red")