Handle dynamic mean_point color

This commit is contained in:
2024-10-05 03:28:02 -04:00
parent 25a5c7ff23
commit 5f8f20a810

View File

@@ -661,7 +661,8 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, page_width
ymin = .data[[y_mean_col]] - .data[[y_sd_col]],
ymax = .data[[y_mean_col]] + .data[[y_sd_col]],
color = .data[[config$color_var]]
)
),
linewidth = 0.1
)
} else {
# If a fixed error bar color is set, use it outside aes
@@ -671,18 +672,32 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, page_width
ymin = .data[[y_mean_col]] - .data[[y_sd_col]],
ymax = .data[[y_mean_col]] + .data[[y_sd_col]]
),
color = config$error_bar_params$color
color = config$error_bar_params$color,
linewidth = 0.1
)
}
# Add the center point if the option is provided
if (!is.null(config$error_bar_params$center_point)) {
plot <- plot + geom_point(aes(
x = .data[[config$x_var]],
y = .data[[y_mean_col]]),
color = config$error_bar_params$color,
shape = 16
)
if (!is.null(config$error_bar_params$mean_point) && config$error_bar_params$mean_point) {
if (!is.null(config$color_var) && is.null(config$error_bar_params$color)) {
plot <- plot + geom_point(
aes(
x = .data[[config$x_var]],
y = .data[[y_mean_col]],
color = .data[[config$color_var]]
),
shape = 16
)
} else {
plot <- plot + geom_point(
aes(
x = .data[[config$x_var]],
y = .data[[y_mean_col]]
),
color = config$error_bar_params$color,
shape = 16
)
}
}
}
@@ -946,7 +961,7 @@ generate_interaction_plot_configs <- function(df_summary, df_interaction, type)
plot_config$error_bar <- TRUE
plot_config$error_bar_params <- list(
color = "red",
center_point = TRUE,
mean_point = TRUE,
y_mean_col = paste0("mean_mean_", var),
y_sd_col = paste0("mean_sd_", var)
)