plot_bar {COINr} | R Documentation |
Bar chart
Description
Plot bar charts of single indicators. Bar charts can be coloured by an optional grouping variable by_group
, or if
iCode
points to an aggregate, setting stack_children = TRUE
will plot iCode
coloured by its underlying scores.
Usage
plot_bar(
coin,
dset,
iCode,
...,
uLabel = "uCode",
axes_label = "iCode",
by_group = NULL,
filter_to_ends = NULL,
dset_label = FALSE,
log_scale = FALSE,
stack_children = FALSE,
bar_colours = NULL,
flip_coords = FALSE
)
Arguments
coin |
A coin object. |
dset |
Data set from which to extract the variable to plot. Passed to |
iCode |
Code of variable or indicator to plot. Passed to |
... |
Further arguments to pass to |
uLabel |
How to label units: either |
axes_label |
How to label the y axis and group legend: either |
by_group |
Optional group variable to use to colour bars. Cannot be used if |
filter_to_ends |
Optional way to filter the bar chart to only display the top/bottom N units. This is useful in cases
where the number of units is large. Specify as e.g. |
dset_label |
Logical: whether to include the data set in the y axis label. |
log_scale |
Logical: if |
stack_children |
Logical: if |
bar_colours |
Optional vector of colour codes for colouring bars. |
flip_coords |
Logical; if |
Details
This function uses ggplot2 to generate plots, so the plot can be further manipulated using ggplot2 commands.
See vignette("visualisation
) for more details on plotting.
Value
A ggplot2 plot object.
Examples
# build example coin
coin <- build_example_coin(up_to = "new_coin", quietly = TRUE)
# bar plot of CO2 by GDP per capita group
plot_bar(coin, dset = "Raw", iCode = "CO2",
by_group = "GDPpc_group", axes_label = "iName")