Learn R Programming

xts (version 0.14.1)

axTicksByTime: Compute x-Axis Tickmark Locations by Time

Description

Compute x-axis tickmarks like axTicks() in base but with respect to time. This function is written for internal use, and documented for those wishing to use it for customized plots.

Usage

axTicksByTime(
  x,
  ticks.on = "auto",
  k = 1,
  labels = TRUE,
  format.labels = TRUE,
  ends = TRUE,
  gt = 2,
  lt = 30
)

Value

A numeric vector of index element locations where tick marks should be drawn. These are locations (e.g. 1, 2, 3, ...), not the index timestamps.

If possible, the result will be named using formatted values from the index timestamps. The names will be used for the tick mark labels.

Arguments

x

An object indexed by time or a vector of times/dates.

ticks.on

Time unit for tick locations.

k

Frequency of tick locations.

labels

Should a labeled vector be returned?

format.labels

Either a logical value specifying whether labels should be formatted, or a character string specifying the format to use.

ends

Should the ends be adjusted?

gt

Lower bound on number of tick locations.

lt

Upper bound on number of tick locations.

Author

Jeffrey A. Ryan

Details

The default ticks.on = "auto" uses heuristics to compute sensible tick locations. Use a combination of ticks.on and k to create tick locations at specific intervals. For example, ticks.on = "days" and k = 7 will create tick marks every 7 days.

When format.labels is a character string the possible values are the same as those listed in the Details section of strptime().

See Also

endpoints()

Examples

Run this code

data(sample_matrix)
axTicksByTime(as.xts(sample_matrix),'auto')
axTicksByTime(as.xts(sample_matrix),'weeks')
axTicksByTime(as.xts(sample_matrix),'months',7)

Run the code above in your browser using DataLab