Use more precalculated values in plots
This commit is contained in:
@@ -368,8 +368,14 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!is.null(config$add_smooth) && config$add_smooth) {
|
if (!is.null(config$add_smooth) && config$add_smooth) {
|
||||||
|
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 + geom_smooth(method = "lm", se = FALSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plot <- plot +
|
plot <- plot +
|
||||||
geom_errorbar(aes(
|
geom_errorbar(aes(
|
||||||
@@ -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") +
|
"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),
|
annotate("text", x = 0, y = 0, label = config$correlation_text),
|
||||||
|
|
||||||
"box" = plot + geom_boxplot(),
|
"box" = plot + geom_boxplot(),
|
||||||
|
|||||||
Reference in New Issue
Block a user