forecast (version 7.2)

plot.forecast: Forecast plot

Description

Plots historical data with forecasts and prediction intervals.

autoplot will produce an equivalent plot as a ggplot object.

Usage

"plot"(x, include, plot.conf=TRUE, shaded=TRUE, shadebars=(length(x$mean)<5), shadecols="NULL," col="1," fcol="4," pi.col="1," pi.lty="2," ylim="NULL," main="NULL," xlab="" ,="" ylab="" type="l" flty="1," flwd="2," ...)="" "autoplot"(object,="" include,="" plot.conf="TRUE," "plot"(x,="" fitcol="2," pch="19," ...)<="" div="">

Arguments

x
Forecast object produced by forecast.
object
Forecast object produced by forecast. Used for ggplot graphics (S3 method consistency).
include
number of values from time series to include in plot. Default is all values.
plot.conf
Logical flag indicating whether to plot prediction intervals.
shaded
Logical flag indicating whether prediction intervals should be shaded (TRUE) or lines (FALSE)
shadebars
Logical flag indicating if prediction intervals should be plotted as shaded bars (if TRUE) or a shaded polygon (if FALSE). Ignored if shaded=FALSE. Bars are plotted by default if there are fewer than five forecast horizons.
shadecols
Colors for shaded prediction intervals. To get default colors used prior to v3.26, set shadecols="oldstyle".
col
Colour for the data line.
fcol
Colour for the forecast line.
flty
Line type for the forecast line.
flwd
Line width for the forecast line.
pi.col
If shaded=FALSE and plot.conf=TRUE, the prediction intervals are plotted in this colour.
pi.lty
If shaded=FALSE and plot.conf=TRUE, the prediction intervals are plotted using this line type.
ylim
Limits on y-axis.
main
Main title.
xlab
X-axis label.
ylab
Y-axis label.
fitcol
Line colour for fitted values.
type
1-character string giving the type of plot desired. As for plot.default.
pch
Plotting character (if type=="p" or type=="o").
...
Other plotting parameters to affect the plot.

Value

References

Hyndman and Athanasopoulos (2014) Forecasting: principles and practice, OTexts: Melbourne, Australia. http://www.otexts.org/fpp/

See Also

plot.ts

Examples

Run this code

wine.fit <- hw(wineind,h=48)
plot(wine.fit)
autoplot(wine.fit)

fit <- tslm(wineind ~ fourier(wineind,4))
fcast <- forecast(fit, newdata=data.frame(fourier(wineind,4,20)))
autoplot(fcast)

fcast <- splinef(airmiles,h=5)
plot(fcast)
autoplot(fcast)

Run the code above in your browser using DataCamp Workspace