Upper/Lower Bars
Source:vignettes/articles/gallery-upper-lower-bars.Rmd
gallery-upper-lower-bars.RmdYou can plot error bars (or any other high/low oriented data) along
with a series by simply specifying the lower, value, and upper series
together in the dySeries() name parameter. For example:
hw <- HoltWinters(ldeaths)
p <- predict(hw, n.ahead = 72, prediction.interval = TRUE)
dygraph(p, main = "Predicted Lung Deaths (UK)") |>
dySeries(c("lwr", "fit", "upr"), label = "Deaths")Here’s how you would plot the actual and predicted series on the same graph:
hw <- HoltWinters(ldeaths)
p <- predict(hw, n.ahead = 36, prediction.interval = TRUE)
all <- cbind(ldeaths, p)
dygraph(all, "Deaths from Lung Disease (UK)") |>
dySeries("ldeaths", label = "Actual") |>
dySeries(c("p.lwr", "p.fit", "p.upr"), label = "Predicted")Finally, here’s an example that plots multiple series each of which have upper and lower bars:
library(quantmod)
getSymbols(c("MSFT", "HPQ"), from = "2014-06-01", auto.assign = TRUE)## [1] "MSFT" "HPQ"