Remove legend but keep space error

12 views
Skip to first unread message

lily li

unread,
Dec 30, 2017, 11:02:03 PM12/30/17
to ggp...@googlegroups.com
Hi ggplot users,

I want to plot three panels on one figure, and remove the legends of 2nd and 3rd panels but keep the legend space. So I use the code below:

g2 <- ggplotGrob(plot3)
g2[['grobs']][[which(g2$layout$name=='guide-box')]][['grobs']] <-NULL

g3 <- ggplotGrob(q1)
g3[['grobs']][[which(g3$layout$name=='guide-box')]][['grobs']] <- NULL

figcom <- gridExtra::grid.arrange(plot1.2,g2,g3)

But it has the warning, where is the problem and should I check? Thanks.

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found

lily li

unread,
Dec 30, 2017, 11:06:22 PM12/30/17
to ggp...@googlegroups.com
This is another error message, but I'm not familiar with. Thanks for your help.

Error in mapply(wrap_gtableChild, x$grobs, children_vps, SIMPLIFY = FALSE) : 
  zero-length inputs cannot be mixed with those of non-zero length

lily li

unread,
Dec 31, 2017, 12:44:47 AM12/31/17
to ggp...@googlegroups.com
Sorry for the email again, I referred to this website but don't have an account.

There is one solution to use grid.arrange function, but why my case does not work? Thanks for any help.
Reply all
Reply to author
Forward
0 new messages