Use more precalculated values in plots

This commit is contained in:
2024-09-12 00:59:43 -04:00
parent 2d3a0b5add
commit d010f52e85

View File

@@ -368,7 +368,13 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
}
if (!is.null(config$add_smooth) && config$add_smooth) {
plot <- plot + geom_smooth(method = "lm", se = FALSE)
if (!is.null(config$lm_line)) {
# Use precomputed linear model values if available
plot <- plot + geom_abline(intercept = config$lm_line$intercept, slope = config$lm_line$slope)
} else {
# Fallback to dynamically calculating the smooth line
plot <- plot + geom_smooth(method = "lm", se = FALSE)
}
}
plot <- plot +
@@ -405,7 +411,7 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
},
"correlation" = plot + geom_point(shape = config$shape %||% 3, color = "gray70") +
geom_smooth(method = "lm", color = "tomato3") +
geom_abline(intercept = config$lm_line$intercept, slope = config$lm_line$slope, color = "tomato3") +
annotate("text", x = 0, y = 0, label = config$correlation_text),
"box" = plot + geom_boxplot(),