patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

error when composing aligned plots

Open nitrato opened this issue 4 years ago • 1 comments

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]] ### `

nitrato avatar Jul 06 '21 14:07 nitrato

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

thomasp85 avatar Aug 08 '23 09:08 thomasp85