Skip to contents

plot_rngflows generates a scatterplot for two flow variables (such as those produced by calc_flowstats) and overlays two convex hulls: one showing the full range of flow conditions experienced historically, and a second convex hull showing the range of flow conditions with associated biology records. This allows the user to assess to coverage of the biology data with respect to the historical range of flow conditions.

Usage

plot_rngflows (data, flow_stats, biol_metric, wrap_by = NULL, plotly = FALSE, label = NULL)

Arguments

data

Name of data frame or tibble containing the data to be analysed, such as that produced by the join_he function.

flow_stats

Vector of two flow statistics to be plotted.

biol_metric

Name of column containing biology data; NAs are interpreted as indicating the absence of a sample.

wrap_by

Grouping variable to facet the plot (e.g. site). Default = NULL.

label

Optional variable (e.g. date) to label points in plotly plot. Default = NULL.

plotly

Logical value specifying whether or not to render the plot as an interactive plotly plot. Default = FALSE.

Value

A single ggplot2 or plotly object.

Examples

## Example 1: Produce a single plotly plot, combining data for all sites
# plot_rngflows(data = all_data,
#               flow_stats = c("Q95z", "Q10z"),
#               biol_metric = "LIFE_F_OE",
#               wrap_by = NULL,
#               label = "Year")

## Example 2: Produce a faceted ggplot, showing data separately for each site
# plot_rngflows(data = all_data,
#               flow_stats = c("Q95z", "Q10z"),
#               biol_metric = "LIFE_F_OE",
#               wrap_by = "biol_site_id",
#               label = "Year")

## Example 3: Create biology records for each time step (uses join_he function)
# all.combinations <- expand.grid(biol_site_id = unique(biol_data$biol_site_id),
#                                 Year = min(biol_data$Year):max(biol_data$Year),
#                                 Season = c("Spring", "Autumn"),
#                                 stringsAsFactors = FALSE)
# biol_data <- all.combinations %>%
#   left_join(biol_data)
# mapping <- master_data[, c("biol_site_id", "flow_site_id")]
# join_data <- join_he(biol_data = biol_data,
#                      flow_stats = flowstats,
#                      mapping = mapping,
#                      lags = c(0, 1),
#                      method = "A",
#                      join_type = "add_biol")
# plot_rngflows(data = all_data,
#               flow_stats = c("Q95z", "Q10z"),
#               biol_metric = "LIFE_F_OE",
#               wrap_by = "biol_site_id",
#               label = "Year")