Given two ggplots, we can arange them side-by-side
library(ggplot2)
library(gridExtra)
# Data
data(iris)
df <- data.frame(y = rnorm(100))
# Plotting
p1 <- qplot(data=iris, Sepal.Width, Sepal.Length)
p2 <- ggplot(df, aes(x=1:100, y=y)) + geom_line()
grid.arrange(p1, p2, ncol=2)
How can we do it if one of the plots is a ggpair
object?
library(GGally)
p1 <- ggpairs(iris, colours='Species')
p2 <- ggplot(df, aes(x=1:100, y=y)) + geom_line()
grid.arrange(l, p2, ncol=6)
# Error in gList(list(list(data = list(Sepal.Length = c(5.1, 4.9, 4.7,
# 4.6, : only 'grobs' allowed in "gList"