Fix default error bar calculations
This commit is contained in:
@@ -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
|
# 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
|
plot <- plot + geom_errorbar(aes(
|
||||||
ymax_value <- config$error_bar_params$ymax
|
ymin = config$error_bar_params$ymin,
|
||||||
|
ymax = config$error_bar_params$ymax,
|
||||||
|
color = error_bar_color))
|
||||||
} 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 <- df[[y_mean_col]] - df[[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 = .data[[y_mean_col]] - .data[[y_sd_col]],
|
||||||
ymax = ymax_value,
|
ymax = .data[[y_mean_col]] + .data[[y_sd_col]],
|
||||||
color = error_bar_color))
|
color = error_bar_color))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plotly_plot <- suppressWarnings(plotly::ggplotly(plot))
|
plotly_plot <- suppressWarnings(plotly::ggplotly(plot))
|
||||||
|
|
||||||
static_plots[[i]] <- plot
|
static_plots[[i]] <- plot
|
||||||
plotly_plots[[i]] <- plotly_plot
|
plotly_plots[[i]] <- plotly_plot
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user