hydrograph | R Documentation |
Creates a ggplot hydrograph from any of CRHM flows, WSC daily flows and/or WSC peak flows.
hydrograph(
CRHMflows = NULL,
CRHMflowsLabels = "",
CRHMcols = NULL,
CRHMdaily = FALSE,
WSCdailyFlowsID = NULL,
WSCdailyFlowsLabel = "",
WSCpeakFlowsID = NULL,
WSCpeakFlowsLabel = "",
forceMissingPeakTimes = FALSE,
commonTime = FALSE,
fakeDates = FALSE,
quiet = TRUE,
hydat_path = NULL
)
CRHMflows |
Optional. A data frame of CRHM modelled flows. The flows must be in
m |
CRHMflowsLabels |
Optional. Labels for the CRHM data. If not specified, and CRHM data are plotted, then the name(s) of the CRHM variables will be used. |
CRHMcols |
Required. Column(s) containing the flowrates. As always, the
numbers do not include the |
CRHMdaily |
Optional. Should CRHM flows be plotted as daily values? Default is |
WSCdailyFlowsID |
Optional. If |
WSCdailyFlowsLabel |
Optional. Labels for the daily flows. If not specified, then the WSC station number will be used, followed by daily. |
WSCpeakFlowsID |
Optional. If |
WSCpeakFlowsLabel |
Optional. Labels for the annual peak flows. If not specified, then the WSC station ID will be used, followed by annual peak. |
forceMissingPeakTimes |
Optional. Some peaks may be missing their time of day
and/or time zone. If |
commonTime |
Optional. If set to |
fakeDates |
Optional. If set to |
quiet |
Optional. Suppresses display of messages, except for errors. If you are
calling this function in an R script, you will usually leave |
hydat_path |
Optional. Path to the HYDAT database. This can usually be left blank. |
If successful, returns a ggplot2 object. If unsuccessful, returns an error.
The CRHM flows are plotted as lines, the daily flows are plotted as steps, and the annual peaks are plotted as points.
Kevin Shook
## Not run:
p <- hydrograph(CRHMflows = "BadLakeModelOutput", CRHMflowsLabels = "CRHM Bad Lake model",
CRHMcols = 1, WSCpeakFlowsID = "05HF014")
# once the ggplot graph has been returned, it can easily be modified:
mintime <- as.POSIXct(as.Date("1975-04-01", format = "%Y-%m-%d"), tz = "etc/GMT+6")
maxtime <- as.POSIXct(as.Date("1975-04-30", format = "%Y-%m-%d"), tz = "etc/GMT+6")
# load in all of ggplot2 to modify plots
# library(ggplot2)
p <- p + xlim(mintime, maxtime) + ylim(0, 4)
# re-plot with fake dates
p2 <- hydrograph(
CRHMflows = "BadLakeModelOutput", CRHMflowsLabels = "CRHM Bad Lake model",
CRHMcols = 1, WSCdailyFlowsID = "05HF014", WSCpeakFlowsID = "05HF014",
commonTime = TRUE, fakeDates = TRUE
)
p2 <- p2 + facet_wrap(~year, scales = "free_y", ncol = 8)
# set axis limits to be the specified date range, and set labels to be the month names
mintime <- as.POSIXct(as.Date("2000-03-01", format = "%Y-%m-%d"), tz = "etc/GMT+6")
maxtime <- as.POSIXct(as.Date("2000-06-30", format = "%Y-%m-%d"), tz = "etc/GMT+6")
p2 <- p2 + scale_x_datetime(date_breaks = "1 month", limits = c(mintime, maxtime),
date_labels = "%b")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.