I'm trying to arrange multiple plots using grid.arrange
.
It does the job by the book, and when calling:
p1 <- ggplot(subset(mtcars, cyl = 4), aes(wt, mpg, colour = cyl)) + geom_point()
p2 <- ggplot(subset(mtcars, cyl = 8), aes(wt, mpg, colour = cyl)) + geom_point()
grid.arrange(p1, p2, ncol = 2)
I get two nice plots, symmetrical in size:
My graphs refer to different parameters but they do share the same colour coding for groups. So I'd like to remove the legend from all but one and find a nice place for it.
However when I try:
p3 <- ggplot(subset(mtcars, cyl = 8), aes(wt, mpg, colour = cyl)) + geom_point() + guides(colour=FALSE)
grid.arrange(p3, p2, ncol = 2)
The plot without the legend gets (correctly) bigger:
I'd like to keep the size (as a length of x axis) to stay the same across graphs.
I'm aware I could use faceting here, but I'll also need to combine various graphs that (I think) will be hard to implement using facets..
Is it possible to do it with grid.arrange
? Any other solutions that could help here?
grid.arrange
by facetting. But there's noclass
column inmtcars
for me to show that. – Daleth