Skip to content

Commit

Permalink
fix: overview plots scaling issue
Browse files Browse the repository at this point in the history
- ts_validation.png
- pareto_clusters_detail.png
  • Loading branch information
gufengzhou committed Jul 19, 2023
1 parent 9415d33 commit 7239391
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 4 additions & 7 deletions R/R/clusters.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,12 @@ robyn_clusters <- function(input, dep_var_type, all_media = NULL, k = "auto", li
write.csv(output$data, file = paste0(path, "pareto_clusters.csv"))
write.csv(output$df_cluster_ci, file = paste0(path, "pareto_clusters_ci.csv"))
ggsave(paste0(path, "pareto_clusters_wss.png"), plot = output$wss, dpi = 500, width = 5, height = 4)
db <- wrap_plots(
A = output$plot_clusters_ci,
B = output$plot_models_rois,
C = output$plot_models_errors,
design = "AA\nBC"
)
get_height <- ceiling(k / 2) / 2
db <- (output$plot_clusters_ci / (output$plot_models_rois + output$plot_models_errors)) +
patchwork::plot_layout(heights = c(get_height, 1), guides = "collect")
# Suppressing "Picking joint bandwidth of x" messages
suppressMessages(ggsave(paste0(path, "pareto_clusters_detail.png"),
plot = db, dpi = 500, width = 12, height = 14
plot = db, dpi = 500, width = 12, height = 4 + length(all_paid) * 2
))
}

Expand Down
6 changes: 4 additions & 2 deletions R/R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ robyn_plots <- function(InputCollect, OutputCollect, export = TRUE, ...) {
}
} # End of !hyper_fixed

get_height <- ceiling(12 * OutputCollect$OutputModels$trials / 3)
if (isTRUE(OutputCollect$OutputModels$ts_validation)) {
ts_validation_plot <- ts_validation(OutputCollect$OutputModels, quiet = TRUE, ...)
ggsave(
paste0(OutputCollect$plot_folder, "ts_validation", ".png"),
plot = ts_validation_plot, dpi = 300,
width = 10, height = 12, limitsize = FALSE
width = 10, height = get_height, limitsize = FALSE
)
}

Expand Down Expand Up @@ -1408,9 +1409,10 @@ ts_validation <- function(OutputModels, quiet = FALSE, ...) {
theme_lares(background = "white", legend = "top", pal = 2) +
scale_x_abbr()

get_height <- max(resultHypParam$trial)
pw <- (pNRMSE / pIters) +
patchwork::plot_annotation(title = "Time-series validation & Convergence") +
patchwork::plot_layout(heights = c(2, 1), guides = "collect") &
patchwork::plot_layout(heights = c(get_height, 1), guides = "collect") &
theme_lares(background = "white", legend = "top")
return(pw)
}
Expand Down

0 comments on commit 7239391

Please sign in to comment.