Skip to content

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

@occamkg

Description

@occamkg

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions