PlotAnnualRegime: Plot annual regimes

View source: R/function_PlotAnnualRegime.R

PlotAnnualRegimeR Documentation

Plot annual regimes

Description

Convenience wrapper function for a combined line plot with polygon variation ranges.

Usage

PlotAnnualRegime(
  x,
  line = c("mean", "median"),
  band = c("none", "p05p95", "p25p75", "minmax"),
  add.legend = FALSE,
  l.legend = NULL,
  l.position = c("topright", "bottomright", "right", "topleft", "left", "bottomleft"),
  log = FALSE,
  ylim = NULL,
  ylab = expression(paste("Q (m"^3, " s"^{
     -1
 }, ")")),
  xlab = paste(format(attr(x, "period"), format = "%Y"), collapse = " to "),
  col = "blue",
  alpha = 30,
  lty = 1,
  lwd = 1,
  mar = c(3, 3, 1, 1) + 0.1,
  verbose = TRUE
)

Arguments

x

List, typically a result from AnnualRegime, containing data frames with aggregated long-term average regime data and two attributes period and timestep. See Details and Value sections there.

line

Character string, keyword for type of average line to plot. Either "mean" or "median".

band

Character vector, keyword for variation bands. If "none" (default), plot average line(s) only. "minmax", "p25p75", or p5p95 to include bands of variation. Combinations of bands are allowed, but providing "none" will always prevent plotting of any band. See details.

add.legend

Logical. If TRUE, a legend will be added to the plot.

l.legend

Character vector. If non-NULL, legend labels are read from here instead of from column names in x$mean.

l.position

Legend position, keyword string. One of "left", "topleft", "topright", "right", "bottomright", "bottomleft".

log

Logical, if TRUE, y-axis will be log-scaled.

ylim

Numeric vector of length two, giving y-axis limits. Defaults to min-max range of all plotted data.

ylab

Character or plotmath expression string. Y-axis label, with a default for discharge regimes.

xlab

Character string or plotmath expression string, x-axis label. Default prints the time period on which the regime is based, read from x$period.

col

Line color specification, see par for details. Defaults to blue. Either a single value or a vector of the same length as quantile series in freq.

alpha

Numeric, alpha transparency value for variation bands. Value between 0 (transparent) and 255 (opaque), see also rgb

lty

Line type specification, see par for details. Either a single value or a vector of the same length as quantile series in freq.

lwd

Line width specification, see par for details. Either a single value or a vector of the same length as quantile series in freq.

mar

Numeric vector of length 4, margin specification as in par with modified default. Details see there.

verbose

Logical, print warnings if NA values are found in x. Defaults to TRUE.

Details

PlotAnnualRegime plots contents from lists as returned by AnnualRegime (for format details, see there). If NA values are present in the plot data, the function will throw a warning if verbose = TRUE and proceed with plotting all available data.

Argument band allows to plot variation bands to be plotted in addition to average lines. These can be (combinations of) ranges between minima and maxima, 5th and 95th percentiles, and 25th and 75th percentiles, i.e. all moments available in AnnualRegime results.

Grid lines plotted in the background are mid-month lines.

Value

PlotAnnualRegime returns a plot to the currently active plot device.

See Also

AnnualRegime, PlotSimObsRegime

Examples

# Source data, HYPE basin output with a number of result variables
te1 <- ReadBasinOutput(filename = system.file("demo_model",
                                              "results", "0003587.txt",
                                              package = "HYPEtools"))
# Daily discharge regime, computed and observed,
# hydrological year from October, aggregated to weekly means
te2 <- AnnualRegime(te1[, c("DATE", "COUT", "ROUT")],
                    ts.in = "day",
                    ts.out = "week", start.mon = 10)
                    
# Screen devices should not be used in examples
## Not run: 
PlotAnnualRegime(x = te2)
PlotAnnualRegime(x = te2, line = "median", band = "p05p95",
  add.legend = TRUE, col = c("red", "blue"))

## End(Not run)


rcapell/RHYPE documentation built on Feb. 28, 2024, 3:11 p.m.