Description Usage Arguments Details
This is the generic that dispatches different methods (below) according to class of list.q
1 | barchart(list.q, query, frc, reg = "Global")
|
list.q |
list of queries, each query a single data.frame |
query |
string, query must be in list.q |
reg |
string, one of 32 GCAM regions or Global. Defaults to Global |
This plotting function outputs a *stacked* barchart. Queries which can be plotted using this function need to have at least one more column than the base set of columns. The base set of columns is units, scenario, forcing, branch, year, region, value. Technology and sector are common columns which contain the keys which make a *stacked* barchart possible. constructPlot() is used in each method, and requires a column that indicates the levels that each get their own color in the "stack", as indicated in the plot's legend.
Because barcharts can only be plotted for one forcing target, all methods require some dataPrep(), which is found in utils.R. This function simply grabs the query data and filters it according to user-input region and forcing target. Without any input, region defaults to "Global". dataPrep() outputs this filtered query data as well as a string that combines query, region, and forcing. This string is later used as the plot title.
The final image is a grid of barcharts, where columns distinguish scenario-runs and rows distinguish which branch of model development the scenarios were run on.
barchart methods output a list whose first entry is the ggplot object, and the second entry is the plot title. This is meant to facilitate programatically saving image files to a directory.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.