hydrometDiscrete: Discrete hydromet data plotting

View source: R/hydrometDiscrete.R

hydrometDiscreteR Documentation

Discrete hydromet data plotting

Description

[Stable]

Generate plots of snow survey data (SWE and depth) or other variables sampled at regular intervals (weekly or monthly).

Notice: in many cases, you're better off using the Shiny app at WRBfloods::hydroApp() to generate and export your plot. Read on if you need additional control over the final product.

This function plots data from the local hydrometric database (maintained by the WRBdatabase package) and yields consistent-looking plots for discrete data. This function can only plot what's in the database, use the function DB_browse_ts() to see what's in there first. Data can be represented as violin plots, as regular box plots or as a 'linedbox' plot (imitates plots currently used in the snow bulletin).

Usage

hydrometDiscrete(
  location = NULL,
  parameter,
  startDay = 1,
  endDay = 365,
  tzone = "MST",
  years = NULL,
  title = TRUE,
  plot_type = "violin",
  plot_scale = 1,
  save_path = NULL,
  dbPath = "default",
  discrete_data = NULL
)

Arguments

location

The location for which you want a plot.

parameter

The parameter you wish to plot. The location:parameter combo must be in the local database.

startDay

NOT CURRENTLY IN USE The start day of year for the plot x-axis. Can be specified as a number from 1 to 365, as a character string of form "yyyy-mm-dd", or as a date object. Either way the day of year is the only portion used, specify years to plot under parameter years.

endDay

NOT CURRENTLY IN USE The end day of year for the plot x-axis. As per startDay.

tzone

The timezone to use for fetching data. Datetimes are stored in the database in UTC offset, so this parameter could make a difference to what day a particular sample is considered to be on. In most cases you can ignore this parameter.

years

The years to plot. If startDay and endDay cover December 31 - January 1, select the December year(s). Max 10 years, NULL = current year.

title

Should a title be included?

plot_type

Choose from "violin" , "boxplot" or "linedbox".

plot_scale

Adjusts/scales the size of plot text elements. 1 = standard size, 0.5 = half size, 2 = double the size, etc. Standard size works well in a typical RStudio environment.

save_path

Default is NULL and the graph will be visible in RStudio and can be assigned to an object. Option "choose" brings up the File Explorer for you to choose where to save the file, or you can also specify a save path directly.

dbPath

The path to the local hydromet database, passed to hydroConnect().

discrete_data

A dataframe with the data to be plotted. Must contain the following columns: year, month, value and units.

Value

A .png file of the plot requested (if a save path has been selected), plus the plot displayed in RStudio. Assign the function to a variable to also get a plot in your global environment as a ggplot object which can be further modified


YukonWRB/WRBplots documentation built on Sept. 29, 2023, 2:05 p.m.