| axis_t | R Documentation |
Auxiliary function axis_t returns a six-element list with axis
limits (in Cartesian coordinates), tick-mark positions (in Cartesian
coordinates), tick-mark labels (character vector), positioning of minor
tick-marks (in Cartesian coordinates), resolution of indices (in Cartesian
coordinates), and limits argument converted to a tinterval
of the same index type as x. The results can be used for manual creation
of axes in plots.
axis_t(
x,
limits = NULL,
format = NULL,
locale = NULL,
expand = FALSE,
n.breaks = 5L
)
x |
time indices for which an axis is to be created. |
limits |
|
format |
(optional) a character string determining label format
(see |
locale |
(optional) a character string determining locale to be used for formatting labels, see calendar-names for information on locale settings. |
expand |
a logical value. If |
n.breaks |
an integer value, desired number of breaks. |
A six-element list with scale limits (lim), vector of tick-mark
positions (at), character vector with tick-mark labels (labels),
vector of minor tick-mark positions (minor), resolution (in Cartesian
coordinates) of time indices (resolution), and limits argument
converted to a tinterval of the same index type as x (limits).
pretty for computing pretty breakpoints,
axis.tind for creating axes with graphics package,
scale_tind for creating axes with ggplot2.
# load graphics
library(graphics)
# artificial data
N <- 180
df <- data.frame(d = today() + (-N + 1):0, y = cumsum(rnorm(N)))
(axt <- axis_t(df$d, format = "%m/%d/%y", n.breaks = 6L))
# custom time axis with minor breaks
plot(df$d, df$y, xlim = axt$lim, type = "l", xaxt = "n", xaxs = "i")
axis(1, at = axt$lim, labels = FALSE, lwd = 1, lwd.ticks = 0)
axis(1, at = axt$at, labels = axt$labels, lwd = 0, lwd.ticks = .7)
axis(1, at = axt$minor, labels = FALSE, lwd = 0, lwd.ticks = .4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.