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

axis.tindR Documentation

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

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.

Value

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

See Also

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

Examples


# 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)



tind documentation built on Dec. 28, 2025, 1:06 a.m.