Add a horizontal or vertical line to the current plot
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 isFALSE
.- H
Logical; if
TRUE
(default), a horizontal line is added. IfFALSE
, a vertical line is added.- ...
Additional graphical parameters passed to graphics::abline.
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")