Fix default error bar calculations
This commit is contained in:
@@ -433,7 +433,7 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
|
|||||||
aes_mapping <- aes(x = .data[[config$x_var]])
|
aes_mapping <- aes(x = .data[[config$x_var]])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# For other plot types
|
# For scatter and other plot types
|
||||||
if (!is.null(config$y_var) && !is.null(config$color_var)) {
|
if (!is.null(config$y_var) && !is.null(config$color_var)) {
|
||||||
aes_mapping <- aes(x = .data[[config$x_var]], y = .data[[config$y_var]], color = .data[[config$color_var]])
|
aes_mapping <- aes(x = .data[[config$x_var]], y = .data[[config$y_var]], color = .data[[config$color_var]])
|
||||||
} else if (!is.null(config$y_var)) {
|
} else if (!is.null(config$y_var)) {
|
||||||
@@ -465,17 +465,18 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
|
|||||||
} else {
|
} else {
|
||||||
"red"
|
"red"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Use error_bar_params if provided, otherwise calculate from mean and sd
|
||||||
if (!is.null(config$error_bar_params$ymin) && !is.null(config$error_bar_params$ymax)) {
|
if (!is.null(config$error_bar_params$ymin) && !is.null(config$error_bar_params$ymax)) {
|
||||||
ymin_value <- config$error_bar_params$ymin
|
ymin_value <- config$error_bar_params$ymin
|
||||||
ymax_value <- config$error_bar_params$ymax
|
ymax_value <- config$error_bar_params$ymax
|
||||||
} else {
|
} else {
|
||||||
y_mean_col <- paste0("mean_", config$y_var)
|
y_mean_col <- paste0("mean_", config$y_var)
|
||||||
y_sd_col <- paste0("sd_", config$y_var)
|
y_sd_col <- paste0("sd_", config$y_var)
|
||||||
ymin_value <- !!sym(y_mean_col) - !!sym(y_sd_col)
|
ymin_value <- df[[y_mean_col]] - df[[y_sd_col]]
|
||||||
ymax_value <- !!sym(y_mean_col) + !!sym(y_sd_col)
|
ymax_value <- df[[y_mean_col]] + df[[y_sd_col]]
|
||||||
}
|
}
|
||||||
|
|
||||||
plot <- plot + geom_errorbar(aes(
|
plot <- plot + geom_errorbar(aes(
|
||||||
ymin = ymin_value,
|
ymin = ymin_value,
|
||||||
ymax = ymax_value,
|
ymax = ymax_value,
|
||||||
|
|||||||
Reference in New Issue
Block a user