From a45b977b0de7e4e3baf8682f7abd4141da2f66a6 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Wed, 25 Sep 2024 19:38:50 -0400 Subject: [PATCH] Add theme_publication() to generate_and_save_plots() --- .../apps/r/calculate_interaction_zscores.R | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R b/qhtcp-workflow/apps/r/calculate_interaction_zscores.R index 94b63827..2d05e2e9 100644 --- a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R +++ b/qhtcp-workflow/apps/r/calculate_interaction_zscores.R @@ -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) }