More axes scaling support
This commit is contained in:
@@ -376,14 +376,27 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
|||||||
plot <- plot + geom_smooth(method = "lm", se = FALSE)
|
plot <- plot + geom_smooth(method = "lm", se = FALSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plot <- plot +
|
if (!is.null(config$x_breaks) && !is.null(config$x_labels) && !is.null(config$x_label) && config$plot_type != "box") {
|
||||||
geom_errorbar(aes(
|
plot <- plot + scale_x_continuous(
|
||||||
ymin = !!sym(paste0("mean_", config$y_var)) - !!sym(paste0("sd_", config$y_var)),
|
name = config$x_label,
|
||||||
ymax = !!sym(paste0("mean_", config$y_var)) + !!sym(paste0("sd_", config$y_var))),
|
breaks = config$x_breaks,
|
||||||
width = 0.1) +
|
labels = config$x_labels
|
||||||
geom_point(aes(y = !!sym(paste0("mean_", config$y_var))), size = 0.6)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is.null(config$ylim_vals)) {
|
||||||
|
plot <- plot + scale_y_continuous(limits = config$ylim_vals)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is.null(config$delta_bg_point) && config$delta_bg_point) {
|
||||||
|
plot <- plot +
|
||||||
|
geom_errorbar(aes(
|
||||||
|
ymin = !!sym(paste0("mean_", config$y_var)) - !!sym(paste0("sd_", config$y_var)),
|
||||||
|
ymax = !!sym(paste0("mean_", config$y_var)) + !!sym(paste0("sd_", config$y_var))),
|
||||||
|
width = 0.1) +
|
||||||
|
geom_point(aes(y = !!sym(paste0("mean_", config$y_var))), size = 0.6)
|
||||||
|
}
|
||||||
plot
|
plot
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -414,25 +427,19 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
|||||||
geom_abline(intercept = config$lm_line$intercept, slope = config$lm_line$slope, 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 <- plot + geom_boxplot()
|
||||||
|
if (!is.null(config$x_breaks) && !is.null(config$x_labels) && !is.null(config$x_label) && config$plot_type == "box") {
|
||||||
|
plot <- plot + scale_x_discrete(
|
||||||
|
name = config$x_label,
|
||||||
|
breaks = config$x_breaks,
|
||||||
|
labels = config$x_labels
|
||||||
|
)
|
||||||
|
}},
|
||||||
"density" = plot + geom_density(),
|
"density" = plot + geom_density(),
|
||||||
"bar" = plot + geom_bar()
|
"bar" = plot + geom_bar()
|
||||||
)
|
)
|
||||||
|
|
||||||
# Conditionally apply scale_x_continuous if x_breaks, x_labels, and x_label are present
|
|
||||||
if (!is.null(config$x_breaks) && !is.null(config$x_labels) && !is.null(config$x_label)) {
|
|
||||||
plot <- plot + scale_x_continuous(
|
|
||||||
name = config$x_label,
|
|
||||||
breaks = config$x_breaks,
|
|
||||||
labels = config$x_labels
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Conditionally apply scale_y_continuous if ylim_vals is present
|
|
||||||
if (!is.null(config$ylim_vals)) {
|
|
||||||
plot <- plot + scale_y_continuous(limits = config$ylim_vals)
|
|
||||||
}
|
|
||||||
|
|
||||||
plot
|
plot
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user