Skip to contents

This function plots the hydrograph separation variables produced by gr_summarize(). Different background fill colors and line types are used to differentiate seasons and variable types.

Usage

gr_plot_vars(
  df,
  ...,
  tests = NULL,
  exclude = NULL,
  smooth = TRUE,
  layout = as.matrix(1),
  pagebreak = FALSE,
  print = TRUE
)

Arguments

df

data.frame of hydrograph and meteorological variables produced by gr_summarize().

...

Quoted sequence of variable names.

tests

list of tests for the same variables (generated by gr_test_vars() function). If tests are specified, then they are added to the plot.

exclude

Integer vector of years to be excluded from plotting.

smooth

Logical. If TRUE then local smoothing regression is plotted. Defaults to TRUE.

layout

matrix that encodes the order of plotting.

pagebreak

Logical. Whether to break page between plots (gr_report()). Defaults to FALSE.

print

Boolean. Print plot? Defaults to TRUE. Use FALSE if you want to tweak the plot aesthetics before plotting.

Value

list of ggplot2 objects, one for each variable, representing its interannual changes

Examples

library(grwat)

data(spas) # example Spas-Zagorye data is included with grwat package

# separate
sep = gr_separate(spas, params = gr_get_params(reg = 'center'))
#> grwat: data frame is correct
#> grwat: parameters list and types are OK

# summarize from 1965 to 1990
vars = gr_summarize(sep, 1965, 1990)
#> Warning: There were 4 warnings in `dplyr::summarise()`.
#> The first warning was:
#>  In argument: `Dspstart = min(.data$Date[which(.data$Qspri > 0)])`.
#>  In group 10: `Year1 = 1974`.
#> Caused by warning in `min.default()`:
#> ! no non-missing arguments to min; returning Inf
#>  Run `dplyr::last_dplyr_warnings()` to see the 3 remaining warnings.

# plot one selected variable
gr_plot_vars(vars, Qygr) 
#> Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).


# plot two variables sequentially
gr_plot_vars(vars, D10w1, Wsprngr)
#> Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).
#> Warning: Removed 1 rows containing missing values (`geom_point()`).

#> Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).


# four variables in matrix layout with tests calculated on the fly
gr_plot_vars(vars, Qspmax, Qygr, D10w1, Wsprngr,
             layout = matrix(1:4, nrow = 2, byrow = TRUE),
             tests = TRUE) 
#> Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).
#> Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).
#> Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).
#> Warning: Removed 1 rows containing missing values (`geom_point()`).
#> Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).