tidyverse/ggplot2

node overflow error when using facets and patchwork

Closed this issue · 5 comments

I found a problem with using ggplot2 v4.0.0 together with patchwork. The code below results in the following error:

Error in `<current-expression>` : node stack overflow
Error during wrapup: node stack overflow
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

With ggplot2 < 4.0.0, this would produce a plot that combined the line plot and a density plot to the right hand side of it.

Here is the code to reproduce the bug:

library(ggplot2)
library(patchwork)

df <- data.frame(
  sim = rep(1:10, 2),
  value = rnorm(20),
  name = rep(c("A", "B"), each = 10)
)

facet_spec <- facet_grid(name ~ ., scales = "free", switch = "y")

p1 <- ggplot(df, aes(sim, value)) +
  geom_line() +
  facet_spec

p2 <- ggplot(df, aes(y = value)) +
  geom_density() +
  facet_spec

wrap_plots(p1, p2, ncol = 2)

What is the patchwork version that you're using?
I'm not encountering the error you mention when executing your example with patchwork version 1.3.2

I was also using patchwork 1.3.2. I've now updated all other packages (see below), restarted, and now it works. I'm not sure which package update/version is required for this code to work properly. Does ggplot2 v4 have a version dependency among them that I should pay attention to? I don't spot any among the following that are in ggplot2's Imports

install.packages(c("aplot", "bookdown", "boot", "checkmate", "curl", "dbplyr", "dbscan", "dials", "dtplyr", "evaluate", "gmm", "hardhat", "later", "Matrix", "pagedown", "parsnip", "pdftools", "PKI", "ragg", "RcppArmadillo", "RcppParallel", "robustbase", "rsconnect", "rvest", "snowflakeauth", "spdep", "stringr", "text", "textshaping", "topics", "tune", "V8", "workflows", "xaringan", "xfun", "xml2", "yulab.utils"))

Does ggplot2 v4 have a version dependency among them that I should pay attention to?

Yeah I'm also not spotting any among the packages you've listed there. If this is issue is solved by updating packages, then I suggest we leave this issue up for a bit, so that others can find this solution too.

Update: I believe the issue was a reexport/wrapper of a {patchwork} function in {autograph}. This will be updated in the next version of that package, and so we can close this issue now. Thanks for your help.

Thanks for narrowing down this issue