I don't have an answer, but here's a reproducible example that might illustrate the problem (from
library("ggplot2")
library("grid")
p <- qplot(data = mtcars, mpg, hp, geom = "point", colour = cyl)
p1 <- p + opts(legend.position = "none")
p2 <- qplot(data = mtcars, wt, disp, geom = "point", colour = cyl) + opts(legend.position = "none")
legend <- p + opts(keep = "legend_box")
Layout <- grid.layout(nrow = 2, ncol = 2, widths = unit(c(2, 0.4), c("null", "null")), heights = unit(c(1, 1), c("null", "null")))
vplayout <- function(...) {
grid.newpage()
pushViewport(viewport(layout = Layout))
}
subplot <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
vplayout()
print(p1, vp = subplot(1, 1))
print(p2, vp = subplot(2, 1))
print(legend, vp = subplot(1:2, 2))