patchwork
patchwork copied to clipboard
Make plot method robust to grid Viewport errors
A frequent error we see with performance::check_model() is users having the RStudio Plots pane too small for the 3x2 patchwork. This produces an error when grid::grid.draw() is called. This PR uses tryCatch() to catch such errors and give a more helpful error message.
Reprex (make the RStudio Plots pane small):
library(performance)
library(
m <- lm(mpg ~ disp + hp, data = mtcars)
check_model(m)
Before:
Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), :
Viewport has zero dimension(s)
After (in RStudio):
Error: The RStudio 'Plots' window is too small to show this patchwork.
Please make the window larger.
After (not in RStudio):
Error: The viewport is too small to show this patchwork.
Please make it larger.