plot$setSize() in .run() works interactively but fails on Export - looking for best practices
Posted: Fri Feb 06, 2026 8:31 pm
Hi everyone,
I am developing a module that generates plots with dynamic height. I calculate the required height based on user options (number of data rows, groups, etc.), and I am currently calling self$results$plot$setSize() within the .run() function.
I have noticed the following behavior:
My questions are:
I am developing a module that generates plots with dynamic height. I calculate the required height based on user options (number of data rows, groups, etc.), and I am currently calling self$results$plot$setSize() within the .run() function.
I have noticed the following behavior:
- In the Analysis Window: The plot renders correctly with the dynamic height I calculated.
- When Saving/Exporting: The saved image reverts to the default dimensions defined in the .r.yaml file, ignoring the size set in .run().
- Manual Resizing: If I manually resize the plot in the UI and then save, the behavior is inconsistent (sometimes width updates but height doesn't, or it works fine).
My questions are:
- Saving Workflow: How exactly does the saving process work? Does it trigger .run() again, or does it only call the render function?
- Dimension Priority: How does the system determine the dimensions for the exported image? Why is the size set during .run() seemingly ignored during the save process, even though it appears correct in the window (similar to a manual resize)?
- Best Practice: Is .init() the mandatory place to call setSize() for dynamic dimensions? If I depend on calculations that are usually done in .run(), should I move that logic to .init() to ensure exports work correctly?