Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coord_fixed produces strange error #156

Closed
drmowinckels opened this issue Mar 3, 2020 · 0 comments
Closed

coord_fixed produces strange error #156

drmowinckels opened this issue Mar 3, 2020 · 0 comments

Comments

@drmowinckels
Copy link

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 + p1

p2 <- p1 + coord_fixed()

p1 + p2

p3 <- p1 + facet_wrap(~cyl)

p1 + p3

p2 + 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 length

p1 + p4
#> Warning in xList[i] <- valueList: number of items to replace is not a multiple
#> of replacement length

p2 + 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant