detail_plot {GTAPViz} | R Documentation |
Create Comprehensive Bar Charts from HAR and SL4 Data
Description
Generates detailed bar charts to visualize the distribution of impacts across multiple dimensions. Supports top impact filtering, color coding, and fully customizable styling and export options.
Input Data
Usage
detail_plot(
data,
filter_var = NULL,
x_axis_from,
split_by = "Variable",
panel_var = "Experiment",
variable_col = "Variable",
unit_col = "Unit",
desc_col = "Description",
invert_axis = TRUE,
separate_figure = FALSE,
top_impact = NULL,
var_name_by_description = FALSE,
add_var_info = FALSE,
output_path = NULL,
export_picture = TRUE,
export_as_pdf = FALSE,
export_config = NULL,
plot_style_config = NULL
)
Arguments
data |
A data frame or list of data frames containing GTAP results. |
filter_var |
NULL, a vector, a data frame, or a named list specifying filtering conditions.
For example: |
x_axis_from |
Character. Column name used for the x-axis. |
split_by |
Character or vector.
|
panel_var |
Character. Column for panel facets. Default is |
variable_col |
Character. Column name for variable codes. Default is |
unit_col |
Character. Column name for units. Default is |
desc_col |
Character. Column name for variable descriptions. Default is Plot Behavior |
invert_axis |
Logical. If |
separate_figure |
Logical. If |
top_impact |
Numeric or NULL. If specified, shows only the top N impactful values; Variable Display |
var_name_by_description |
Logical. If |
add_var_info |
Logical. If Export Settings |
output_path |
Character. Directory to save plots. If |
export_picture |
Logical. If |
export_as_pdf |
Logical or
|
export_config |
List. Export options including dimensions, DPI, and background.
See Styling |
plot_style_config |
List. Custom plot appearance settings.
See |
Value
A ggplot object or a named list of ggplot objects depending on the separate_figure
setting.
If export_picture
or export_as_pdf
is enabled, the plots are also saved to output_path
.
Author(s)
Pattawee Puangchit
See Also
Examples
# Load Data:
input_path <- system.file("extdata/in", package = "GTAPViz")
sl4.plot.data <- readRDS(file.path(input_path, "sl4.plot.data.rds"))
# Prepare Dataframe
sector_data <- sl4.plot.data[["COMM*REG"]]
# Plot
plotB <- detail_plot(
# === Input Data ===
data = sector_data,
filter_var = list(Region = "Oceania"),
x_axis_from = "Commodity",
split_by = "Region",
panel_var = "Experiment",
variable_col = "Variable",
unit_col = "Unit",
desc_col = "Description",
# === Plot Behavior ===
invert_axis = TRUE,
separate_figure = FALSE,
top_impact = NULL,
# === Variable Display ===
var_name_by_description = TRUE,
add_var_info = FALSE,
# === Export Settings ===
output_path = NULL,
export_picture = FALSE,
export_as_pdf = FALSE,
export_config = create_export_config(width = 45, height = 20),
# === Styling ===
plot_style_config = create_plot_style(
positive_color = "#2E8B57",
negative_color = "#CD5C5C",
panel_rows = 1,
panel_cols = NULL,
show_axis_titles_on_all_facets = FALSE,
y_axis_text_size = 25,
bar_width = 0.6,
all_font_size = 1.1
)
)