Skip to contents

The plot_predictions function produces a time series plot of predictions from a hydro-ecological model, alongside observed biology and flow data. The plot is faceted by site, as specified by the site_col argument. The function generates a ggplot object, that is optionally saved as a .png file named "Predictions_Plot.png".

Usage

plot_predictions(data, biol_metric, time_col, site_col, flow_stat, pred_col, ncol = 4, save = FALSE, save_dir = getwd())

Arguments

data

Data to plot, containing observed biology and flow data as well as model predictions.

biol_metric

Name of column containing measured data for the biology metric of interest.

time_col

Name of column containing time variable for x-axis.

site_col

Name of column containing biology site ID, for faceting. Default = "biol_site_id".

flow_stat

Names of up to two flow statistics of interest.

pred_col

Names of columns containing central predictions (required) and lower and upper confidence or prediction intervals (optional). The lower and upper limits are optional but both must be specified (not just a lower or upper limit).

ncol

Number of columns to use in facet plots. Default = 4.

save

Logical value specifying whether or not the output should also be saved as a png file. Default = FALSE.

save_dir

Path to folder where png files are to be saved. Default = Current working directory.

Value

The function returns a single ggplot object.

Examples

# Generate a plot of predictions from a hydro-ecological model, alongside observed biology and flow data, and save a png file to a sub-folder of the working directory called 'outputs'.
# plot_predictions(data = autumn_data,
#                  biol_metric = "LIFE_F_OE",
#                  time_col = "Year",
#                  site_col = "biol_site_id",
#                  flow_stat = c("Q95z", "Q10z"),
#                  pred_col = c("fit", "lwr", "upr"),
#                  ncol = 4)