View source: R/basinWaterBalancePlot.R
basinWaterBalancePlot | R Documentation |
Creates a stacked bar plot of all water balance components computed for a basin. Basin inputs are plotted as positive values, outputs are plotted as negative.
basinWaterBalancePlot(yearlyWater, negCols = "")
yearlyWater |
Required. A data frame of water balance components. The first column must be the year. Note that this function does not allow you to select columns - all columns will be plotted. |
negCols |
Optional. Columns to be plotted as negative values. If not specified (the default) the columns will be guessed from their names. |
If successful returns a ggplot2 object showing stacked bars of the water balance components for each year.
If unsuccessful returns FALSE
.
Kevin Shook. Idea from http://www.r-bloggers.com/improved-net-stacked-distribution-graphs-via-ggplot2-trickery/
## Not run:
# get daily water balance from CRHM output
daily <- simpleDailyWater(Bol84, prjFile = 'Bologna1984_02.prj',
basinMean = TRUE, summarize = TRUE)
# get yearly values
daily.datetime <- dateToDatetime(daily, timezone='Etc/GMT+7')
yearly <- aggDataframe(daily.datetime, period='hydro', funs='sum')
# plot
p <- basinWaterBalancePlot(yearly)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.