Fix default error bar calculations

This commit is contained in:
2024-10-02 14:05:39 -04:00
parent 964d2ad9b2
commit e856102851

View File

@@ -468,23 +468,21 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs) {
# 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)) {
ymin_value <- config$error_bar_params$ymin
ymax_value <- config$error_bar_params$ymax
plot <- plot + geom_errorbar(aes(
ymin = config$error_bar_params$ymin,
ymax = config$error_bar_params$ymax,
color = error_bar_color))
} else {
y_mean_col <- paste0("mean_", config$y_var)
y_sd_col <- paste0("sd_", config$y_var)
ymin_value <- df[[y_mean_col]] - df[[y_sd_col]]
ymax_value <- df[[y_mean_col]] + df[[y_sd_col]]
}
plot <- plot + geom_errorbar(aes(
ymin = ymin_value,
ymax = ymax_value,
ymin = .data[[y_mean_col]] - .data[[y_sd_col]],
ymax = .data[[y_mean_col]] + .data[[y_sd_col]],
color = error_bar_color))
}
}
plotly_plot <- suppressWarnings(plotly::ggplotly(plot))
static_plots[[i]] <- plot
plotly_plots[[i]] <- plotly_plot
}