Plot Time Series During Trading Hours
Plot a time series after removing weekends and specific times of the day.
plot_trading_hours(x, t = NULL, interval = "5 min", labels = "hours", label.format = NULL, exclude.weekends = TRUE, holidays = NULL, fromHHMMSS = "000000", toHHMMSS = "240000", do.plot.axis = TRUE, ..., from = NULL, to = NULL, do.plot = TRUE, axis1.par = list())
x |
A numeric vector. Can also be of class |
t |
A vector that inherits from class |
interval |
A character string like “num units”, in which |
labels |
A character vector of length one, determining the grid for
|
label.format |
See |
exclude.weekends |
logical: default is |
holidays |
a vector of class |
fromHHMMSS |
a character vector of length one in format “HHMMSS” |
toHHMMSS |
a character vector of length one in format “HHMMSS” |
do.plot.axis |
logical. Should |
... |
|
from |
POSIXct: start plot at (if not specified, plot starts at first data point) |
to |
POSIXct: end plot at (if not specified, plot ends at last data point) |
do.plot |
logical. Should anything be plotted? Default is |
axis1.par |
a list of named elements |
Plot a timeseries during specific times of day.
A list (invisibly if do.plot
is TRUE
):
list(t, x, axis.pos = pos, axis.labels, timegrid)
t |
positions |
x |
values |
axis.pos |
positions of x-tickmarks |
axis.labels |
labels at x-ticks |
timegrid |
a POSIXct vector |
map |
a function. See the manual (a link is under References). |
Enrico Schumann <es@enricoschumann.net>
B.D. Ripley and K. Hornik. Date-Time Classes. R-News, 1(2):8–12, 2001.
E. Schumann (2020) Portfolio Management with R. http://enricoschumann.net/PMwR/
t <- as.POSIXct("2012-08-31 08:00:00") + 0:32400 x <- runif(length(t)) par(tck = 0.001, mgp = c(3,1,0.5), bty = "n") p <- plot_trading_hours(x, t, interval = "5 min", labels = "hours", xlab = "time", ylab = "random points", col = "blue") ## with ?lines t <- as.POSIXct("2012-08-31 10:00:00") + 0:9000 x <- seq(0, 1, length.out = 9001) lines(p$map(t)$t, x[p$map(t)$ix], pch = 19)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.