This function generates a water balance plot using a data frame in long format. It refactors the variable names, sums total values of variables to accurately reflect inputs and outputs, and creates faceted plots for the different variables. The function handles data for both CABCM and Terra Climate datasets, producing a combined plot that shows both the faceted bar plots and the total water balance.
Arguments
- x
A data frame in long format (e.g., output from `balance_data()`), containing columns for `divide_id`, `var`, `value`, and `lab`. The data should be specific to either CABCM or Terra Climate.
Value
This function does not return a value. It displays and prints a combined plot consisting of:
A faceted bar plot showing the summed values of each variable, facetted by the `lab` column.
A combined bar plot showing the positive and negative values of variables, with different colors for each variable.
Details
The `CreateWaterBalancePlot` function performs the following operations:
**Data Refactoring**: Reorders the data and assigns labels to the variables.
**Faceted Bar Plot**: Creates a faceted bar plot showing the summed values for each variable by `divide_id`.
**Combined Water Balance Plot**: Generates a stacked bar plot combining positive and negative values with custom color palettes for CABCM and Terra Climate datasets.
**Color Mapping**: Uses custom color palettes to differentiate between various variables.
**Plot Combination**: Combines the faceted and total water balance plots into a single grid layout.