Learn R Programming

tind (version 0.2.4)

axis.tind: Add Time Axis --- Plotting with graphics Package

Description

axis.tind adds time axis to a plot. Axes will be added automatically by graphics, but the default behaviour can be overridden by plotting without axis and then calling axis.tind, see Examples.

Usage

axis.tind(
  side,
  x,
  at,
  format = NULL,
  locale = NULL,
  labels = TRUE,
  n.breaks = 5L,
  ...
)

Value

Same as for axis, used for its side effect, which is to add time axis to an existing plot.

Arguments

side

see axis.

x

time indices for which an axis is to be created.

at

(optional) time indices at which manual tick-marks and labels should be placed.

format

(optional) a character string determining label format or a formatting function, see format.

locale

(optional) a character string determining locale to be used for formatting labels, see calendar-names for information on locale settings.

labels

a logical value determining whether automatic labels should be placed at tick-marks or a character vector of labels.

n.breaks

an integer value, desired number of breaks.

...

further arguments passed to axis.

See Also

pretty for computing pretty breakpoints, axis_t for calculating axis parameters, scale_tind for creating axes with ggplot2.

Examples

Run this code
# \donttest{
# load graphics
library(graphics)
# artificial data
N <- 100
df <- data.frame(d = today() + (-N + 1):0, y = cumsum(rnorm(N)))
# default axis
plot(df$d, df$y, type = "l")
# custom date format with potentially more breaks and a smaller font
plot(df$d, df$y, type = "l", xaxt = "n")
axis.tind(1, df$d, format = "%m/%d/%y", n.breaks = 7L, cex.axis = .9)
# }

Run the code above in your browser using DataLab