patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

`free()` in nested patchwork breaks `/`, `|`, and `-` operators

Open occamkg opened this issue 9 months ago • 2 comments

Using free() in a nested patchwork and trying to add a plot below with / throws an error. This also applies to the | and - operators regardless of whether the nesting is implicit or explicit.

Here are examples that throw the error:

p <- iris %>%
  ggplot(aes(x = Sepal.Length, y = Sepal.Width)) +
  geom_point()

(p + free(p)) / p
>> Error in split.default(names(settings), settings): first argument must be a vector

p / (p + free(p))
>> Error in split.default(names(settings), settings): first argument must be a vector

p + p / free(p)
>> Error in split.default(names(settings), settings): first argument must be a vector

p + free(p) | p
>> Error in split.default(names(settings), settings): first argument must be a vector

p + free(p) - p
>> Error in split.default(names(settings), settings): first argument must be a vector

Interestingly, it's fine if the free is not the final plot in the nested patchwork:

(free(p) + p) / p

Also, using design works:

(p + free(p)) + p + plot_layout(design = "AB\nCC")

Without nesting is also fine:

free(p) / p

occamkg avatar Jun 06 '25 21:06 occamkg

I have the same problem, throws the same error when nested.

eejd avatar Aug 06 '25 14:08 eejd

I have the same problem, throws the same error when nested.

piechottam avatar Sep 01 '25 13:09 piechottam