Description Usage Arguments Value Note Author(s) See Also Examples
View source: R/simpleHydrograph.R
Creates a ggplot hydrograph from MESH output. This function only uses
values from a single MESH data frame (as read in using readOutputTimeseriesCSV
), so does
not work with outside sources, such as WSC files. Because this function returns a
ggplot object, you can change its format in any way you like.
The plots produced may be faceted using the commands facet_wrap
or facet_grid
.
1 2 3 4 5 6 7 8 9 10 11 | simpleHydrograph(
MESHvals,
stationNames = "",
byStation = TRUE,
byYear = FALSE,
meas = TRUE,
sim = TRUE,
calStart = "",
calEnd = "",
alpha = 1
)
|
MESHvals |
Required. A data frame of output from a MESH run, as produced by |
stationNames |
Optional. A vector of strings holding station names. If specified, the station names will be used in the plots. Otherwise the MESH station numbers will be used. |
byStation |
Optional. If |
byYear |
Optional. If |
meas |
Optional. Should the measured values be plotted? Default is |
sim |
Optional. Should the simulated values be plotted? Default is |
calStart |
Optional. The start date of the calibration period. Must be a string in the format yyyy-mm-dd. If specified, values on and after this date will be designated as the |
calEnd |
Optional. The start date of the calibration period. Must be a string in the format yyyy-mm-dd. If specified, values on and after this date will be designated as the |
alpha |
Optional. Sets the alpha channel (transparency) of the plots. The default value is |
If successful, returns a ggplot2 object. If unsuccessful, returns FALSE
. The object can be facetted by the name of the station (the variable is called station
). If the option byYear = TRUE
, then the object can be facetted by the variable YEAR
.
Specifying the calibration start and/or end dates will allow the resulting plot to be facetted by the variable period
.
Kevin Shook
read_MESH_OutputTimeseries_csv
hydroStats
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # plot hydrograph of all data on single graph
p1 <- simpleHydrograph(MESH_streamflows)
p1
# add station names, and replot
stations <- c("Station1", "Station2")
p2 <- simpleHydrograph(MESH_streamflows, stationNames = stations)
p2
# remove colouring by station, and facet, changing the axis label format
p3 <- simpleHydrograph(MESH_streamflows, stationNames = stations, byStation = FALSE)
# load in all of ggplot2 to modify plots
library(ggplot2)
p3 <- p3 + facet_wrap(~station, nrow = 2) + scale_x_date(date_labels = "%Y")
p3
# plot by year, then facet
p4 <- simpleHydrograph(MESH_streamflows, stationNames = stations, byYear = TRUE)
p4 <- p4 + facet_wrap(~YEAR, scales = "free_y")
p4
# remove colouring for stations, and facet by station and year
p5 <- simpleHydrograph(MESH_streamflows, stationNames = stations, byStation = FALSE, byYear = TRUE)
p5 <- p5 + facet_grid(YEAR~station, scales = "free_y")
# change colours
plotcols <- c("red", "blue")
p5 <- p5 + scale_colour_manual(values = plotcols)
p5
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.