Add theme_publication() to generate_and_save_plots()

This commit is contained in:
2024-09-25 19:38:50 -04:00
parent 453c834566
commit a45b977b0d

View File

@@ -394,7 +394,7 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, grid_layout
}
# Start building the plot with aes_mapping
plot_base <- ggplot(df, aes_mapping) + theme_publication()
plot_base <- ggplot(df, aes_mapping)
# Use appropriate helper function based on plot type
plot <- switch(config$plot_type,
@@ -405,10 +405,9 @@ generate_and_save_plots <- function(out_dir, filename, plot_configs, grid_layout
plot_base # default case if no type matches
)
# Apply additional settings
if (!is.null(config$legend_position)) {
plot <- plot + theme(legend.position = config$legend_position)
}
# Apply theme_publication with legend_position from config
legend_position <- if (!is.null(config$legend_position)) config$legend_position else "bottom"
plot <- plot + theme_publication(legend_position = legend_position)
# Add title and labels
if (!is.null(config$title)) {
@@ -615,11 +614,6 @@ generate_scatter_plot <- function(plot, config) {
plot <- plot + ggtitle(config$title)
}
# Adjust Legend Position if specified
if (!is.null(config$legend_position)) {
plot <- plot + theme(legend.position = config$legend_position)
}
return(plot)
}