library(ggplot2)
library(gridExtra)
p1 <- ggplot(mtcars, aes(disp, wt)) + geom_point()
p2 <- ggplot(mtcars, aes(wt, disp)) + geom_point()
p3 <- grid.arrange(p1, p2)
Running the code grid.arrange(p1, p2)
draws a nice plot of p1 and p2 beside each other. I tried to declare this as p3. But if I run p3 I don't get the same nice plot that the grid.arrange(p1, p2)
gives me. I instead get what's shown below. What's wrong? I want to store grid.arrange(p1, p2)
as a neat variable like p3
.
p3
TableGrob (2 x 1) "arrange": 2 grobs
z cells name grob
1 1 (1-1,1-1) arrange gtable[layout]
2 2 (2-2,1-1) arrange gtable[layout]