plot_forecast_generic: Plot a single model's forecast

View source: R/plot_generic.R

plot_forecast_genericR Documentation

Plot a single model's forecast

Description

Model-agnostic plotly plotting: works off just ds/yhat(+intervals) for models that only produce that, and additionally draws Prophet's trend/holiday/changepoint decomposition when forecast_df still has those columns (pass the adapter's raw forecast() output for that; pass the standardized to_tibble() output to metrics functions instead).

Usage

plot_forecast_generic(
  forecast_df,
  train_df = NULL,
  model_obj = NULL,
  subtitle = NULL,
  title = "Forecast",
  show_trend = TRUE,
  show_uncertainty = TRUE,
  show_holidays = FALSE,
  show_changepoints = FALSE,
  max_marker_lines = 60,
  color_actual = "#1b9e77",
  color_forecast = "#d95f02",
  color_trend = "#7570b3",
  color_ci = "#1b9e77"
)

Arguments

forecast_df

A tibble with ds/yhat (and optionally yhat_lower/yhat_upper/trend/holidays) columns.

train_df

Optional tibble with ds/y columns, drawn as the "Actual" line.

model_obj

Optional fitted model object; only used to read ⁠$changepoints⁠ when show_changepoints = TRUE.

subtitle

Optional character scalar, e.g. an ARIMA/SARIMA annotate() result like "ARIMA(2,1,1)(1,0,0)[12]".

title

Character scalar, the plot title. Default "Forecast".

show_trend, show_uncertainty, show_holidays, show_changepoints

Logical toggles for each optional layer.

max_marker_lines

Integer cap on how many holiday/changepoint marker lines are drawn (evenly subsampled beyond this), so a long horizon with recurring holidays doesn't render as unreadable clutter.

color_actual, color_forecast, color_trend, color_ci

Hex color strings for each line/ribbon.

Value

A plotly htmlwidget.

Examples

ds <- as.Date("2024-01-01") + 0:9
forecast_df <- tibble::tibble(ds = ds, yhat = 1:10)
plot_forecast_generic(forecast_df)

forecastsuite documentation built on Oct. 18, 2026, 5:08 p.m.