Skip to contents

plot method for class "fv_forecast". The type of plot produced can be controlled using the target and type arguments with the latter only being functional when target is set to "posterior" or "forecast".


# S3 method for fv_forecast
plot(x, obs = NULL, target = "posterior", type = "cases", ...)



A data.table of output as produced by forecast() of class "fv_forecast".


A data frame of observed data as produced by latest_obs().


A character string indicating the target object within the forecast() to produce plots for. Current options are: posterior predictions ("posterior"), posterior forecasts ("forecast"), and the model fit ("fit"). When "posterior" or "forecast" are used then plot.fv_posterior() is called whereas when "fit" is used plot_pairs() is used.


A character string indicating the type of plot required, defaulting to "cases". Current options are: "cases" which calls plot_cases(), "voc_frac" which calls plot_voc_frac(), "voc_advantage" which calls plot_voc_advantage(), "growth" which calls plot_growth(), "rt" which calls plot_rt(), and "all" which produces a list of all plots by call plot_posterior().


Pass additional arguments to lower level plot functions.


ggplot2 object

See also


Functions used for forecasting across models, dates, and scenarios forecast_across_dates(), forecast_across_scenarios(), forecast_n_strain(), forecast(), summary.fv_forecast(), unnest_posterior()

Plotting functions add_forecast_dates(), plot.fv_posterior(), plot_cases(), plot_default(), plot_growth(), plot_pairs(), plot_posterior(), plot_rt(), plot_theme(), plot_voc_advantage(), plot_voc_frac(), save_plots()


if (FALSE) { # interactive()
options(mc.cores = 4)

forecasts <- forecast(
  forecast_date = as.Date("2021-06-12"),
  horizon = 4,
  strains = c(1, 2),
  adapt_delta = 0.99,
  max_treedepth = 15,
  variant_relationship = "scaled"
# inspect forecasts

# plot case posterior predictions
plot(forecasts, log = TRUE)

# plot case posterior predictions with central estimates
plot(forecasts, log = TRUE, central = TRUE)

# plot voc posterior predictions
plot(forecasts, type = "voc_frac")