-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Description
I'm getting an error when I try to use patchwork on a faceted ggplot with a manually-placed legend (i.e. theme(legend.position = ...)). Here's a reprex.
library(ggplot2)
library(patchwork)
p1 <- ggplot(mtcars, aes(mpg, disp, col = as.factor(gear))) +
geom_point() +
facet_wrap(~ cyl) +
theme(legend.position = c(0.1, 0.7))
# plot by itself
p1# plot within patchwork
p1 / p1
#> Error in FUN(X[[i]], ...): subscript out of bounds
wrap_plots(p1, p1)
#> Error in FUN(X[[i]], ...): subscript out of boundsCreated on 2020-01-06 by the reprex package (v0.3.0)
It works fine when I remove the facet_wrap(), or the theme(legend.position = ...) line. Something about both of them together seems to cause an issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
