Skip to content

Commit

Permalink
fix: size limit error for roas_convergence plot fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
gufengzhou committed Feb 25, 2022
1 parent 9b77b99 commit eb0dc8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
36 changes: 21 additions & 15 deletions R/R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,27 @@ robyn_plots <- function(InputCollect, OutputCollect, export = TRUE) {
dt_ridges <- dt_ridges[!is.na(iter_bin)]
dt_ridges[, iter_bin := factor(iter_bin, levels = sort(set_bin, decreasing = TRUE))]
dt_ridges[, trial := as.factor(trial)]
all_plots[["pRidges"]] <- pRidges <- ggplot(
dt_ridges, aes(x = roi_total, y = iter_bin, fill = as.integer(iter_bin), linetype = trial)) +
scale_fill_distiller(palette = "GnBu") +
geom_density_ridges(scale = 4, col = "white", quantile_lines = TRUE, quantiles = 2, alpha = 0.7) +
facet_wrap(~ variables, scales = "free") +
guides(fill = "none")+
theme(panel.background = element_blank()) +
labs(x = "Total ROAS", y = "Iteration Bucket"
,title = "ROAS distribution over iteration"
,fill = "iter bucket")
if (export) suppressMessages(ggsave(
paste0(OutputCollect$plot_folder, "roas_convergence.png"),
plot = pRidges, dpi = 600, width = 12,
height = ceiling(InputCollect$mediaVarCount / 3) * 6
))
plot_vars <- dt_ridges[, unique(variables)]
plot_n <- ceiling(length(plot_vars) / 6)
for (pl in 1:plot_n) {
loop_vars <- na.omit(plot_vars[(1:6)+6*(pl-1)])
dt_ridges_loop <- dt_ridges[variables %in% loop_vars, ]
all_plots[[paste0("pRidges",pl)]] <- pRidges <- ggplot(
dt_ridges_loop, aes(x = roi_total, y = iter_bin, fill = as.integer(iter_bin), linetype = trial)) +
scale_fill_distiller(palette = "GnBu") +
geom_density_ridges(scale = 4, col = "white", quantile_lines = TRUE, quantiles = 2, alpha = 0.7) +
facet_wrap(~ variables, scales = "free") +
guides(fill = "none")+
theme(panel.background = element_blank()) +
labs(x = "Total ROAS", y = "Iteration Bucket"
,title = "ROAS distribution over iteration"
,fill = "iter bucket")
if (export) suppressMessages(ggsave(
paste0(OutputCollect$plot_folder, "roas_convergence",pl,".png"),
plot = pRidges, dpi = 600, width = 12,
height = ceiling(length(loop_vars) / 3) * 6
))
}
}
} # End of !hyper_fixed

Expand Down
2 changes: 1 addition & 1 deletion demo/demo.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ OutputModels <- robyn_run(
#, cores = NULL # default
#, add_penalty_factor = FALSE # Untested feature. Use with caution.
, iterations = 2000 # recommended for the dummy dataset
, trials = 1 # recommended for the dummy dataset
, trials = 5 # recommended for the dummy dataset
, outputs = FALSE # outputs = FALSE disables direct model output
)
print(OutputModels)
Expand Down

0 comments on commit eb0dc8e

Please sign in to comment.