Skip to contents

Generates a time series plot comparing simulated and observed values (e.g., streamflow) from the outputs of evaluate_swat.

Usage

plot_timeseries(
  data,
  x_label = "Time",
  y_label = "Q [m3/s]",
  show_legend = TRUE
)

Arguments

data

data frame. Time series of simulated and observed values, typically one of the outputs from evaluate_swat (daily_data, monthly_data, or annual_data).

x_label

character. Label for the x-axis. Default is "Time".

y_label

character. Label for the y-axis. Default is "Q [m3/s]".

show_legend

logical. Whether to display the legend. Default is TRUE.

Value

A ggplot object representing the time series plot of observed and simulated values.

Examples

tmpdir <- tempdir()
get_swat_example(tmpdir)
rch_file <- file.path(tmpdir, "TxtInOut", "output.rch")
rch_data <- output_rch(
  file = rch_file, variable = "FLOW_OUTcms",
  target_id = 3, time_step = "daily",
  output_start_date = "2011-01-01"
)

observed_data <- tibble::tibble(
  Date = qobserved$Date,
  value = qobserved$Flow,
  target_id = 3
)

evaluation_results <- evaluate_swat(
  rch_output = rch_data,
  observed_data = observed_data,
  target_id = 3,
  variable = "FLOW_OUTcms",
  metrics = c("NSE","KGE","MAE","PBIAS"),
  start_dates = c("2011-01-01","2014-01-01"),
  end_dates = c("2013-12-31","2015-12-31")
)

# Plot daily time series of observed vs simulated flow
plot_timeseries(evaluation_results$daily_data)