Skip to contents

Creates a dual-axis plot comparing precipitation and runoff over time.

Usage

plot_pcp_vs_flow(
  pcp_file,
  flow,
  x_label = "Date",
  y_left = "Runoff (m3/s)",
  y_right = "Precipitation (mm)",
  title = "Precipitation and Runoff"
)

Arguments

pcp_file

Character string specifying the path to the precipitation data file. The file should contain columns: year (integer), yday (integer), pcp (numeric, in mm).

flow

Data frame with at least two columns: date (Date) and discharge (numeric, in m³/s).

x_label

Character string for x-axis label. Defaults to "Date".

y_left

Character string for left y-axis label (runoff). Defaults to "Runoff (m³/s)".

y_right

Character string for right y-axis label (precipitation). Defaults to "Precipitation (mm)".

title

Character string for plot title. Defaults to "Precipitation and Runoff".

Value

A ggplot2 object representing the dual-axis plot.

Examples

if (FALSE) {
pcp_file_path <- "path/to/my_station.pcp"
flow_data <- data.frame(date = as.Date("2023-01-01") + 0:364, discharge = runif(365, 0, 100))
plot_pcp_vs_flow(pcp_file_path, flow_data)
}