我在ggplot
的帮助下在我的R-Script中绘制了不同的图形。
为了比较它们,我需要将它们集成到一个图形中。
这是我单个图表的当前代码:
p1 <- ggplot(merch42, aes(x = day_code, y = avg_logistic_review_score, col = "red"))+
geom_smooth(method = "loess", span = 1/25, col = "red")
p2 <- ggplot(merch323, aes(x = day_code, y = avg_logistic_review_score, col = "blue"))+
geom_smooth(method = "loess", span = 1/25, col = "blue")
p3 <- ggplot(merch24, aes(x = day_code, y = avg_logistic_review_score, col = "green"))+
geom_smooth(method = "loess", span = 1/25, col = "green")
p4 <- ggplot(merch180, aes(x = day_code, y = avg_logistic_review_score, col = "yellow"))+
geom_smooth(method = "loess", span = 1/25, col = "yellow")
p5 <- ggplot(merch505, aes(x = day_code, y = avg_logistic_review_score, col = "merch505"))+
geom_smooth(method = "loess", span = 1/25, col = "black")
有人知道这有用吗? 非常感谢:)菲尔
答案 0 :(得分:0)
使用库中的grid.arrange()
函数gridExtra
。下面给出了最小值:
library(ggplot2)
library(gridExtra)
p1 <- qplot(mpg, wt, data = mtcars, colour = cyl)
p2 <- qplot(mpg, data = mtcars) + ggtitle("title")
p3 <- qplot(mpg, data = mtcars, geom = "dotplot")
p4 <-
p1 + facet_wrap( ~ carb, nrow = 1) + theme(legend.position = "none") +
ggtitle("facetted plot")
# grid.arrange(p1, p2, nrow = 1)
grid.arrange(p1, p2, p3, p4, nrow = 2, ncol=2)