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

error when composing aligned plots #254

Open
nitrato opened this issue Jul 6, 2021 · 1 comment
Open

error when composing aligned plots #254

nitrato opened this issue Jul 6, 2021 · 1 comment

Comments

@nitrato
Copy link

nitrato commented Jul 6, 2021

Hi,
I have a question regarding the very handy patchwork extension to ggplot2. In the following chunk, I wonder why lines that I tagged with ### give me this error:
Error in grid.Call.graphics(C_setviewport, vp, TRUE) :
'layout.pos.row' incorrect

Any help would be highly appreciated
Best,
David

`p1 <- ggplot(msleep) + 
geom_boxplot(aes(x = sleep_total, y = vore, fill = vore)) +
p3 <- ggplot(msleep) + 
geom_point(aes(x = bodywt, y = sleep_total, colour = vore), size = 3, alpha = 0.7)

p1_bis <- p1 + theme(legend.position = "none")
p3_dims <- get_dim(p3)
p1_aligned <- set_dim(p1_bis, p3_dims)
p1_aligned
p1 + p1_aligned ###

plots_aligned <- align_patches(p1, p2, p3, p4)
for (p in plots_aligned)
  plot(p)

plots_aligned[[1]] + plots_aligned[[2]] ### `
@thomasp85
Copy link
Owner

The set_dim() and get_dim() functions are not meant to be used together with further composition but rather to align plots across multiple pages.

Can you describe what you are trying to achieve with your code and I can help you with the right way

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

2 participants