stairs {onlineforecast} | R Documentation |
Plotting stairs with time point at end of interval.
Description
Plotting steps with time point at end of interval
Usage
stairs(x, y, type = "b", preline = FALSE, pch = 19, ...)
Arguments
x |
x values for plot. |
y |
y values for plot. |
type |
if 'b' then include points. |
preline |
if TRUE, then a line backwards from the first point is added. |
pch |
Passed to |
... |
Passed to |
Details
It's easy to plot stairs with plot(x,y,type="s")
, however that makes the steps forward from x
, for time series this works if the time points are at the beginning of the intervals.
Often with time series the time points are in the end of the intervals, so the steps should go backaward, this is achieved with this function.
Examples
# Usual stairs plot has steps forward from x
x <- rnorm(10)
plot(1:10, x, type="s")
# Stairs with step backward from x
plot(1:10, x, type="n")
stairs(1:10, x)
# Use for time series plotting
plot_ts(Dbuilding, "heatload", c("2010-12-15","2010-12-16"), plotfun=stairs)
# Set it globally for all plot_ts
p <- par_ts()
p$plotfun <- stairs
options(par_ts=p)
plot_ts(Dbuilding, "heatload", c("2010-12-15","2010-12-16"))
# Modify it to only lines
plot_ts(Dbuilding, "heatload", c("2010-12-15","2010-12-16"),
plotfun=function(x,y,...){stairs(x,y, type="l")})
[Package onlineforecast version 1.0.2 Index]