Skip to contents

This is a wrapper for plot_time_series() that generates an interactive (plotly) or static (ggplot2) plot with the forecasted data.


  .conf_interval_show = TRUE,
  .conf_interval_fill = "grey20",
  .conf_interval_alpha = 0.2,
  .smooth = FALSE,
  .legend_show = TRUE,
  .legend_max_width = 40,
  .facet_ncol = 1,
  .facet_nrow = 1,
  .facet_scales = "free_y",
  .title = "Forecast Plot",
  .x_lab = "",
  .y_lab = "",
  .color_lab = "Legend",
  .interactive = TRUE,
  .plotly_slider = FALSE,
  .trelliscope = FALSE,
  .trelliscope_params = list(),



A tibble that is the output of modeltime_forecast()


Logical. Whether or not to include the confidence interval as a ribbon.


Fill color for the confidence interval


Fill opacity for the confidence interval. Range (0, 1).


Logical - Whether or not to include a trendline smoother. Uses See smooth_vec() to apply a LOESS smoother.


Logical. Whether or not to show the legend. Can save space with long model descriptions.


Numeric. The width of truncation to apply to the legend text.


Number of facet columns.


Number of facet rows (only used for .trelliscope = TRUE)


Control facet x & y-axis ranges. Options include "fixed", "free", "free_y", "free_x"


Title for the plot


X-axis label for the plot


Y-axis label for the plot


Legend label if a color_var is used.


Returns either a static (ggplot2) visualization or an interactive (plotly) visualization


If TRUE, returns a plotly date range slider.


Returns either a normal plot or a trelliscopejs plot (great for many time series) Must have trelliscopejs installed.


Pass parameters to the trelliscopejs::facet_trelliscope() function as a list(). The only parameters that cannot be passed are:

  • ncol: use .facet_ncol

  • nrow: use .facet_nrow

  • scales: use facet_scales

  • as_plotly: use .interactive


Additional arguments passed to timetk::plot_time_series().


A static ggplot2 plot or an interactive plotly plot containing a forecast



# Data
m750 <- m4_monthly %>% filter(id == "M750")

# Split Data 80/20
splits <- initial_time_split(m750, prop = 0.9)

# --- MODELS ---

# Model 1: prophet ----
model_fit_prophet <- prophet_reg() %>%
    set_engine(engine = "prophet") %>%
    fit(value ~ date, data = training(splits))
#> Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this.
#> Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.


models_tbl <- modeltime_table(

# ---- FORECAST ----

models_tbl %>%
    modeltime_calibrate(new_data = testing(splits)) %>%
        new_data    = testing(splits),
        actual_data = m750
    ) %>%
    plot_modeltime_forecast(.interactive = FALSE)
#> Warning: no non-missing arguments to max; returning -Inf