Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spurious(?) viewport-too-small error with new ggplot2 version 3.5.0 #691

Closed
bbolker opened this issue Mar 2, 2024 · 11 comments · Fixed by #694
Closed

spurious(?) viewport-too-small error with new ggplot2 version 3.5.0 #691

bbolker opened this issue Mar 2, 2024 · 11 comments · Fixed by #694
Assignees

Comments

@bbolker
Copy link

bbolker commented Mar 2, 2024

With performance ver 0.10.8.13, ggplot2 3.4.4 (the next-most-recent version) [and a recent r-devel] this works fine:

m1 <- lm(mpg ~ hp + cyl, data = mtcars)
performance::check_model(m1)

With ggplot2 3.5.0 (published 2024-02-23), I get the following error - even if I set up a large plotting device via pdf(height = 1000, width = 1000) (units for pdf height/width are inches).

Error: The viewport is too small to show this set of plots. You may try one of
  the following steps to resolve this problem.
  
- To fix this issue, please make the window larger.
  
- If this doesn't help, try to reset the zoom settings of your IDE and
  then retry.
  
- If this still doesn't resolve your problems, you may check whether
  your apps are rescaled. On Windows, this can be done in the display
  settings (Start > Settings > System > Display, "Scale and layout").
  Reduce the scaling and try again.
  
- Finally, you can try to decrease the base font-size of your theme
  before plotting. Load `library(ggplot2)` and run:
  `theme_set(theme_classic(base_size = 6))`

Debugging see:::.safe_print_plots and running the print(pw) command by hand shows that the real error is

Error in Ops.data.frame(guide_loc, panel_loc) : ‘==’ only defined for equally-sized data frames

(this error is caught and replaced by the bogus one).

Further debugging shows that this is coming from patchwork:::print.patchwork, specifically from

gtable <- build_patchwork(plot, plot$layout$guides %||% "auto")

I would have thought patchwork would have been thoroughly tested with the new ggplot version but maybe performance+see are building a weird/malformed object that worked OK in previous versions?

Considerably more digging eventually localizes the precise error location here (all(unlist(guide_loc == panel_loc))). guide_loc is 5x4, panel_loc is 1x4 - not sure how this worked in previous versions of ggplot2 ...

The NEWS file for ggplot2 does say that the guide system has completely changed ...

I'm going to revert to ggplot2 3.4.4 for now ...

@strengejacke
Copy link
Member

I just saw we had suggested ggplot 3.5.0 in see. We have a GitHub action that automatically updates the versions in the DESCRIPTION file to the latest CRAN packages. I set back minimum version to ggplot 3.4.0 in see, so if you re-install see from GitHub, it should work with ggplot 3.4.0+.

Anyway, we'll try to figure out what's going on with ggplot 3.5.0

@strengejacke
Copy link
Member

Which IDE are you using? Works fine for me with VSCode:

library(easystats)
#> # Attaching packages: easystats 0.7.0.3
#> ✔ bayestestR  0.13.2     ✔ correlation 0.8.4.2 
#> ✔ datawizard  0.9.1.4    ✔ effectsize  0.8.6.6 
#> ✔ insight     0.19.8.6   ✔ modelbased  0.8.7   
#> ✔ performance 0.10.9.2   ✔ parameters  0.21.5.3
#> ✔ report      0.5.8.1    ✔ see         0.8.2.3
m1 <- lm(mpg ~ hp + cyl, data = mtcars)
performance::check_model(m1)

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.2 (2023-10-31 ucrt)
#>  os       Windows 11 x64 (build 22631)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  German_Germany.utf8
#>  ctype    German_Germany.utf8
#>  tz       Europe/Berlin
#>  date     2024-03-02
#>  pandoc   3.1.11 @ C:/PROGRA~1/Pandoc/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version    date (UTC) lib source
#>  bayestestR        * 0.13.2     2024-02-11 [1] https://easystats.r-universe.dev (R 4.3.2)
#>  benchmarkme         1.0.8      2022-06-12 [1] CRAN (R 4.3.2)
#>  benchmarkmeData     1.0.4      2020-04-23 [1] CRAN (R 4.3.2)
#>  bitops              1.0-7      2021-04-24 [1] CRAN (R 4.3.1)
#>  caTools             1.18.2     2021-03-28 [1] CRAN (R 4.3.2)
#>  cli                 3.6.2      2023-12-11 [1] CRAN (R 4.3.2)
#>  coda                0.19-4.1   2024-01-31 [1] CRAN (R 4.3.2)
#>  codetools           0.2-19     2023-02-01 [1] CRAN (R 4.3.2)
#>  colorspace          2.1-0      2023-01-23 [1] CRAN (R 4.3.2)
#>  correlation       * 0.8.4.2    2024-03-02 [1] https://easystats.r-universe.dev (R 4.3.3)
#>  datawizard        * 0.9.1.4    2024-02-14 [1] https://easystats.r-universe.dev (R 4.3.2)
#>  DEoptimR            1.1-3      2023-10-07 [1] CRAN (R 4.3.1)
#>  digest              0.6.34     2024-01-11 [1] CRAN (R 4.3.2)
#>  doParallel          1.0.17     2022-02-07 [1] CRAN (R 4.3.2)
#>  dplyr               1.1.4      2023-11-17 [1] CRAN (R 4.3.2)
#>  easystats         * 0.7.0.3    2024-02-28 [1] https://easystats.r-universe.dev (R 4.3.2)
#>  effectsize        * 0.8.6.6    2024-03-02 [1] https://easystats.r-universe.dev (R 4.3.3)
#>  emmeans             1.10.0     2024-01-23 [1] CRAN (R 4.3.2)
#>  estimability        1.5        2024-02-20 [1] CRAN (R 4.3.2)
#>  evaluate            0.23       2023-11-01 [1] CRAN (R 4.3.2)
#>  fansi               1.0.6      2023-12-08 [1] CRAN (R 4.3.2)
#>  farver              2.1.1      2022-07-06 [1] CRAN (R 4.3.2)
#>  fastmap             1.1.1      2023-02-24 [1] CRAN (R 4.3.2)
#>  foreach             1.5.2      2022-02-02 [1] CRAN (R 4.3.2)
#>  fs                  1.6.3      2023-07-20 [1] CRAN (R 4.3.2)
#>  generics            0.1.3      2022-07-05 [1] CRAN (R 4.3.2)
#>  ggplot2             3.5.0      2024-02-23 [1] CRAN (R 4.3.2)
#>  ggrepel             0.9.5      2024-01-10 [1] CRAN (R 4.3.2)
#>  glue                1.7.0      2024-01-09 [1] CRAN (R 4.3.2)
#>  gtable              0.3.4      2023-08-21 [1] CRAN (R 4.3.2)
#>  htmltools           0.5.7      2023-11-03 [1] CRAN (R 4.3.2)
#>  httr                1.4.7      2023-08-15 [1] CRAN (R 4.3.2)
#>  insight           * 0.19.8.6   2024-02-29 [1] https://easystats.r-universe.dev (R 4.3.2)
#>  iterators           1.0.14     2022-02-05 [1] CRAN (R 4.3.2)
#>  knitr               1.45       2023-10-30 [1] CRAN (R 4.3.2)
#>  labeling            0.4.3      2023-08-29 [1] CRAN (R 4.3.1)
#>  lattice             0.22-5     2023-10-24 [1] CRAN (R 4.3.2)
#>  lifecycle           1.0.4      2023-11-07 [1] CRAN (R 4.3.2)
#>  magrittr            2.0.3      2022-03-30 [1] CRAN (R 4.3.2)
#>  MASS                7.3-60.0.1 2024-01-13 [1] CRAN (R 4.3.2)
#>  Matrix              1.6-5      2024-01-11 [1] CRAN (R 4.3.2)
#>  memuse              4.2-3      2023-01-24 [1] CRAN (R 4.3.1)
#>  mgcv                1.9-1      2023-12-21 [1] CRAN (R 4.3.2)
#>  modelbased        * 0.8.7      2024-03-02 [1] https://easystats.r-universe.dev (R 4.3.3)
#>  multcomp            1.4-25     2023-06-20 [1] CRAN (R 4.3.2)
#>  munsell             0.5.0      2018-06-12 [1] CRAN (R 4.3.2)
#>  mvtnorm             1.2-4      2023-11-27 [1] CRAN (R 4.3.2)
#>  nlme                3.1-164    2023-11-27 [1] CRAN (R 4.3.2)
#>  opdisDownsampling   0.8.3      2023-12-13 [1] CRAN (R 4.3.2)
#>  parameters        * 0.21.5.3   2024-03-01 [1] https://easystats.r-universe.dev (R 4.3.2)
#>  patchwork           1.2.0      2024-01-08 [1] CRAN (R 4.3.2)
#>  performance       * 0.10.9.2   2024-02-23 [1] https://easystats.r-universe.dev (R 4.3.2)
#>  pillar              1.9.0      2023-03-22 [1] CRAN (R 4.3.2)
#>  pkgconfig           2.0.3      2019-09-22 [1] CRAN (R 4.3.2)
#>  pracma              2.4.4      2023-11-10 [1] CRAN (R 4.3.2)
#>  purrr               1.0.2      2023-08-10 [1] CRAN (R 4.3.2)
#>  qqconf              1.3.2      2023-04-14 [1] CRAN (R 4.3.2)
#>  qqplotr             0.0.6      2023-01-25 [1] CRAN (R 4.3.2)
#>  R.cache             0.16.0     2022-07-21 [1] CRAN (R 4.3.2)
#>  R.methodsS3         1.8.2      2022-06-13 [1] CRAN (R 4.3.1)
#>  R.oo                1.26.0     2024-01-24 [1] CRAN (R 4.3.2)
#>  R.utils             2.12.3     2023-11-18 [1] CRAN (R 4.3.2)
#>  R6                  2.5.1      2021-08-19 [1] CRAN (R 4.3.2)
#>  Rcpp                1.0.12     2024-01-09 [1] CRAN (R 4.3.2)
#>  report            * 0.5.8.1    2024-02-29 [1] https://easystats.r-universe.dev (R 4.3.2)
#>  reprex              2.1.0      2024-01-11 [1] CRAN (R 4.3.2)
#>  rlang               1.1.3      2024-01-10 [1] CRAN (R 4.3.2)
#>  rmarkdown           2.25       2023-09-18 [1] CRAN (R 4.3.2)
#>  robustbase          0.99-2     2024-01-27 [1] CRAN (R 4.3.2)
#>  rstudioapi          0.15.0     2023-07-07 [1] CRAN (R 4.3.2)
#>  sandwich            3.1-0      2023-12-11 [1] CRAN (R 4.3.2)
#>  scales              1.3.0      2023-11-28 [1] CRAN (R 4.3.2)
#>  see               * 0.8.2.3    2024-03-02 [1] local
#>  sessioninfo         1.2.2      2021-12-06 [1] CRAN (R 4.3.2)
#>  styler              1.10.2     2023-08-29 [1] CRAN (R 4.3.2)
#>  survival            3.5-8      2024-02-14 [1] CRAN (R 4.3.2)
#>  TH.data             1.1-2      2023-04-17 [1] CRAN (R 4.3.2)
#>  tibble              3.2.1      2023-03-20 [1] CRAN (R 4.3.2)
#>  tidyselect          1.2.0      2022-10-10 [1] CRAN (R 4.3.2)
#>  twosamples          2.0.1      2023-06-23 [1] CRAN (R 4.3.2)
#>  utf8                1.2.4      2023-10-22 [1] CRAN (R 4.3.2)
#>  vctrs               0.6.5      2023-12-01 [1] CRAN (R 4.3.2)
#>  withr               3.0.0      2024-01-16 [1] CRAN (R 4.3.2)
#>  xfun                0.42       2024-02-08 [1] CRAN (R 4.3.2)
#>  xtable              1.8-4      2019-04-21 [1] CRAN (R 4.3.2)
#>  yaml                2.3.8      2023-12-11 [1] CRAN (R 4.3.2)
#>  zoo                 1.8-12     2023-04-13 [1] CRAN (R 4.3.2)
#> 
#>  [1] C:/Program Files/R/R-4.3.2/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Created on 2024-03-02 with reprex v2.1.0

@bbolker
Copy link
Author

bbolker commented Mar 2, 2024

IDE shouldn't matter (emacs)? But graphics device is x11, also tried pdf. Maybe something else?

@strengejacke
Copy link
Member

Yes, IDE doesn't matter, works in RStudio as well.

image

@bbolker
Copy link
Author

bbolker commented Mar 2, 2024

(won't be able to keep digging/get back to this for a few hours; maybe it's just something weird about my system?)

strengejacke referenced this issue in easystats/see Mar 2, 2024
@IndrajeetPatil
Copy link
Member

We have a GitHub action that automatically updates the versions in the DESCRIPTION file to the latest CRAN packages.

That action updates only easystats packages to their latest CRAN versions.

I bumped the version for ggplot2 today on GitHub because I had to update all the snapshots so that the tests pass on CI, where the latest version of ggplot2 is downloaded.

@bbolker
Copy link
Author

bbolker commented Mar 3, 2024

PS I may work on it some more, but I'm not sure I will easily be able to identify the particular ggplot2 + patchwork combination that triggers the problem. Dianne Cook http://www.dicook.org/ commented on Mastodon that she had had some ggplot+patchwork problems of the same kind, but that they had eventually gone away with package updates.

[opinion]

performance aggressively captures errors and warnings from upstream packages, which can make debugging/troubleshooting difficult (e.g. see #692, #678). I think I understand the rationale for doing things this way (the base-R default of reporting often-unhelpful errors from the bottom of the call stack is not necessarily any better), but it can also backfire. Maybe there could be a debugging flag (set via options(performance.raw.errors = TRUE) that would disable the trapping of errors?

@bwiernik
Copy link
Contributor

bwiernik commented Mar 4, 2024

performance aggressively captures errors and warnings from upstream packages, which can make debugging/troubleshooting difficult (e.g. see #692, #678). I think I understand the rationale for doing things this way (the base-R default of reporting often-unhelpful errors from the bottom of the call stack is not necessarily any better), but it can also backfire. Maybe there could be a debugging flag (set via options(performance.raw.errors = TRUE) that would disable the trapping of errors?

That's a good idea

@strengejacke
Copy link
Member

It will be options(easystats_erros = TRUE) to override the tryCatch(), but only for functions that call the .safe() internally. Not all try-catch-instances will be ignored. Will do this for performance and see for now.

@strengejacke
Copy link
Member

That option should now work for performance, see and parameters. It might take some time (~1 hour?) until all package binaries are built on r-universe.

@bbolker
Copy link
Author

bbolker commented Mar 7, 2024

I'm going to close this since it seems to depend on some particular combination of ggplot2/patchwork that I have now moved beyond ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants