Learn R Programming

RSurvey (version 0.6-0)

AddAxis: Add an Axis to a Plot

Description

Adds an axis to the current plot.

Usage

AddAxis(side, lim, ticks.inside = FALSE, minor.ticks = FALSE, ...)

Arguments

side
integer; a vector of values specifying the plot sides for the axis to be drawn.
lim
numeric or POSIXt; the axis limits (x1, x2) of the plot.
ticks.inside
logical; if TRUE tickmarks are placed inside the plot region; its default is FALSE.
minor.ticks
logical; if TRUE minor tickmarks are added to the plot; its default is FALSE.
...
other graphical parameters may also be passed as arguments to this function.

Details

The plot sides are designated as: 1 = below, 2 = left, 3 = above, and 4 = right.

See Also

axis, axis.POSIXct, seq, pretty

Examples

Run this code
x <- as.POSIXlt("2001/1/1") + 700 * sort(runif(10))
y <- rnorm(10)
xlim <- extendrange(x, f = 0.02)
ylim <- extendrange(y, f = 0.02)
plot(x, y, axes = FALSE)
box()
AddAxis(side = 1, lim = xlim)
AddAxis(side = 2, lim = ylim, ticks.inside = TRUE)
AddAxis(side = 3, lim = xlim, minor.ticks = TRUE)
AddAxis(side = 4, lim = ylim, ticks.inside = TRUE, minor.ticks = TRUE)

Run the code above in your browser using DataLab