Prevent interactive variable collision in generate_plot

This commit is contained in:
2024-09-15 11:58:00 -04:00
parent 8b0212d9b4
commit 767694b8ac

View File

@@ -394,10 +394,10 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
plot_base <- ggplot(df, aes_mapping)
# Function to generate the plot
generate_plot <- function(is_interactive) {
generate_plot <- function(interactive) {
# Use appropriate helper function based on plot type
plot <- switch(config$plot_type,
"scatter" = generate_scatter_plot(plot_base, config, is_interactive = is_interactive),
"scatter" = generate_scatter_plot(plot_base, config, is_interactive = interactive),
"box" = generate_box_plot(plot_base, config),
"density" = plot_base + geom_density(),
"bar" = plot_base + geom_bar(),
@@ -479,7 +479,7 @@ generate_scatter_plot <- function(plot, config, is_interactive = FALSE) {
)
}
# Add the interactive `text` aesthetic if `is_interactive` is TRUE
# Add the interactive text aesthetic if `is_interactive` is TRUE
if (is_interactive) {
if (!is.null(config$delta_bg_point) && config$delta_bg_point) {
plot <- plot + geom_point(
@@ -561,7 +561,7 @@ generate_scatter_plot <- function(plot, config, is_interactive = FALSE) {
plot <- plot + scale_y_continuous(limits = config$ylim_vals)
}
# Add annotations if provided
# Add annotations if specified
if (!is.null(config$annotations)) {
for (annotation in config$annotations) {
plot <- plot + annotate("text", x = annotation$x, y = annotation$y, label = annotation$label)