View source: R/plot_apportionment.R
| plot_apportionment | R Documentation |
Displays the relative contribution of sediment sources to each mixture as density or violin plots. Designed to take the output of unmixing functions directly.
plot_apportionment(
data,
violin = FALSE,
bounds = c(0, 1),
scaled = TRUE,
y_high = 1,
colors = NULL,
vlines = NULL,
title = NULL,
bw = "nrd"
)
plotResults(
data,
violin = FALSE,
bounds = c(0, 1),
scaled = TRUE,
y_high = 1,
colors = NULL,
vlines = NULL,
title = NULL,
bw = "nrd"
)
plot_results(
data,
violin = FALSE,
bounds = c(0, 1),
scaled = TRUE,
y_high = 1,
colors = NULL,
vlines = NULL,
title = NULL,
bw = "nrd"
)
data |
A data frame, typically the output from |
violin |
Logical. If |
bounds |
A numeric vector of length 2 specifying the lower and upper
display bounds (the camera window). Default is |
scaled |
Logical. If |
y_high |
Maximum value for the y-axis. Only used when
|
colors |
An optional named character vector of colors, one per source. Default is |
vlines |
An optional named numeric vector specifying true/expected values
for specific sources. Draws a dashed vertical line to allow visual validation
of the model's accuracy (e.g., |
title |
Optional character string to add a main title to the plot. Default is |
bw |
The smoothing bandwidth to be used. Can be a numeric value (e.g., |
A ggplot object visualizing the source contribution distributions.
# Generate mock unmixing output
set.seed(123)
mock_unmix <- data.frame(
id = 1:100,
gof = runif(100, 85, 95),
SourceA = rnorm(100, mean = 0.45, sd = 0.05),
SourceB = rnorm(100, mean = 0.35, sd = 0.04),
SourceC = rnorm(100, mean = 0.20, sd = 0.03)
)
# Density Plot
plot_apportionment(mock_unmix, title = "Source Contributions (Density)")
# Violin Plot with true values
true_vals <- c("SourceA" = 0.45, "SourceB" = 0.35, "SourceC" = 0.20)
plot_apportionment(
mock_unmix, violin = TRUE,
vlines = true_vals,
title = "Source Contributions (Violin)"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.