Add helpful output to save_plots()

This commit is contained in:
2024-09-01 16:19:34 -04:00
parent d61c7219d7
commit ddb7a98e50

View File

@@ -87,7 +87,6 @@ theme_publication <- function(base_size = 14, base_family = "sans", legend_posit
)
}
scale_fill_publication <- function(...) {
discrete_scale("fill", "Publication", manual_pal(values = c(
"#386cb0", "#fdb462", "#7fc97f", "#ef3b2c", "#662506",
@@ -270,14 +269,21 @@ save_plots <- function(file_name, plot_list, output_dir) {
# Save to HTML with horizontal legend orientation
lapply(names(plot_list), function(plot_name) {
pgg <- suppressWarnings(ggplotly(plot_list[[plot_name]]) %>%
message("Processing plot: ", plot_name)
pgg <- tryCatch({
suppressWarnings(ggplotly(plot_list[[plot_name]]) %>%
layout(legend = list(orientation = "h")))
}, error = function(e) {
message("Error in plot: ", plot_name, "\n", e)
return(NULL)
})
saveWidget(
pgg,
if (!is.null(pgg)) {
saveWidget(pgg,
file = file.path(output_dir,
paste0(file_name, "_", plot_name, ".html")),
selfcontained = TRUE)
}
})
}