One-pager plots are cut-off so not all information is shown (missing legend)
NumesSanguis opened this issue · 3 comments
Project Robyn
Describe issue
After generating the one-pager output PNG with:
OutputCollect <- robyn_outputs(
InputCollect, OutputModels,
pareto_fronts = "auto", # automatically pick how many pareto-fronts to fill min_candidates (100)
# min_candidates = 100, # top pareto models for clustering. Default to 100
# calibration_constraint = 0.1, # range c(0.01, 0.1) & default at 0.1
csv_out = "pareto", # "pareto", "all", or NULL (for none)
clusters = TRUE, # Set to TRUE to cluster similar models by ROAS. See ?robyn_clusters
export = create_files, # this will create files locally
plot_folder = robyn_directory, # path for plots exports and files creation
plot_pareto = create_files # Set to FALSE to deactivate plotting and saving model one-pagers
)
Some of the text is cut-off (maybe the font size is too big)?
As for the "Response Curves and Mean Spends by Channel", which line is which media is not even shown. See this crop of the one-pager:
Provide reproducible example
This seem to be related to R output only, so it seems to unrelated to the calculations of the model.
My first thought was that my names for each variable was too long, but I reduced it to maximum 9 characters, which is shorter than (intercept)
. Still the problem persisted.
Environment & Robyn version
Make sure you're using the latest Robyn version before you post an issue.
- Check and share Robyn version:
‘3.10.5.9000’
- R version: 'R version 4.3.3 (2024-02-29)'
- Run in a Jupyter Lab Notebook on a VM (Vertex AI on Google Cloud Platform)
Workaround
Is it possible to output each figure individually as a PNG as well, besides only all in 1 page? That would be easier for incorporating it in presentations.
It seems likely that it is a font issue. When trying to show a plot, it cannot find the font Arial Narrow
:
## 1. IMPORTANT: set plot = TRUE to create example plots for adstock & saturation
## hyperparameters and their influence in curve transformation.
plot_adstock(plot = TRUE) # FALSE
plot_saturation(plot = TRUE) # FALSE
Gives the error:
Warning message in .font_global(font, quiet = FALSE, ...):
“Font(s) 'Arial Narrow' not installed, with other name, or can't be found”
Warning message in geom_text(aes(x = max(.data$x), y = 0.5, vjust = -0.5, hjust = 1, :
“All aesthetics have length 1, but the data has 900 rows.
ℹ Please consider using `annotate()` or provide this layer with data containing
a single row.”
I documented my attempts to install this font in this issue: #973 (comment)
but without success so far.
It is possible to plot all of the plots individually - there is some code showing this in the demo file. I have copied the most relevant lines below, but you may need to check the demo depending on your own naming conventions etc.
myOnePager <- robyn_onepagers(InputCollect, OutputCollect, select_model, export = FALSE)
# To check each of the one-pager's plots
# myOnePager[[select_model]]$patches$plots[[1]]
Thank you for pointing that out @kevindotmcdonnellatartefactdotcom ! Seems I missed that somehow.
The output of myOnePager[[robyn_model]]$patches$plots[[4]]
actually gives me both the plot "Response Curves and Mean Spend" as well as the plot "Fitted vs. Residual". I was able to get a single plot by appending with [[1]]
and I could save it with ggplot2
:
myplot <- myOnePager[[robyn_model]]$patches$plots[[4]][[1]]
ggplot2::ggsave(
plot = myplot,
filename = paste0(robyn_directory, robyn_model, "_response-curves.png"),
width = 8,
height = 5,
dpi = 200
)
This does give me a Legend. It seems this is not the first time this issue came up:
Related discussions: