-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Description
This is mainly an issue for a better error message when combining plots made with coord_fixed and facets.
The error message is quite cryptic and it tok me a while to figure out that this comes from combinations of coord_fixed and facet_wrap. I'm not sure how feasible it is to catch this and provide a better warning with solution suggestion, but thought it worth making you aware of.
library(ggplot2)
library(patchwork)
# base plots. All below are fine
p1 <- ggplot(mtcars, aes(mpg, disp)) +
geom_point()
p1 + p1p2 <- p1 + coord_fixed()
p1 + p2p3 <- p1 + facet_wrap(~cyl)
p1 + p3p2 + p3# These make errors and look weird.
p4 <- p3 + coord_fixed()
p4 + p4
#> Warning in xList[i] <- valueList: number of items to replace is not a multiple
#> of replacement length
#> Warning in xList[i] <- valueList: number of items to replace is not a multiple
#> of replacement lengthp1 + p4
#> Warning in xList[i] <- valueList: number of items to replace is not a multiple
#> of replacement lengthp2 + p4
#> Warning in xList[i] <- valueList: number of items to replace is not a multiple
#> of replacement length# fixed with plot_layout(width = 1)
p4 + p4 + plot_layout(width = 1)Created on 2020-03-03 by the reprex package (v0.3.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels







