Plot main effects of multiple parameters on an outcome (violin/box/jitter)
Source:R/plot_main_effects.R
plot_main_effects.RdCreates a facetted overview plot showing the distribution of an outcome
(for example n_overflows) across the tested levels of multiple varied
parameters. Parameters are sorted by a simple effect-size proxy: the range of
median outcome values across parameter levels.
Usage
plot_main_effects(
df,
y = "n_overflows",
params,
max_levels = 25,
ylim_lower = 0,
lang = c("de", "en")
)Arguments
- df
A data.frame or tibble containing the outcome column
yand the parameter columns listed inparams.- y
Character scalar. Name of the outcome column to plot on the y-axis. Defaults to
"n_overflows".- params
Character vector of parameter column names in
dfto consider.- max_levels
Integer. Parameters with more than
max_levelsdistinct values are dropped to keep the plot readable. Defaults to 25.- ylim_lower
Numeric scalar or
NULL. Optional lower display limit for the y-axis. Usesggplot2::coord_cartesian(), so data are not removed before computing violin and boxplots. Defaults to0.- lang
Character. Plot language:
"de"or"en".
Details
The function is intended for optimisation or sensitivity grids with many parameters, where a single 2D scatter plot is not informative.
Both numeric and character parameters are supported; a character parameter
such as storage_type gets its own facet panel (its levels are shown
as Sickerbox / Schotterrigol for lang = "de",
Infiltration box / Gravel trench for lang = "en").
The plot language can be switched via lang = "de" or
lang = "en". This affects the title, y-axis label, and selected
parameter labels.