我一直在考虑使用par()或layout()函数来组合ggplots.是否可以使用这些功能?
假设我想绘制散点图的ggplot和直方图的ggplot.我希望将这两个图组合在一起(不是在单个画面中).适用吗?
我在R中使用简单的绘图尝试了它,而没有使用ggplot函数.它确实有效.
以下是来自Quick-R的示例链接:http://www.statmethods.net/advgraphs/layout.html
# 4 figures arranged in 2 rows and 2 columns
attach(mtcars)
par(mfrow=c(2,2))
plot(wt,mpg, main="Scatterplot of wt vs. mpg")
plot(wt,disp, main="Scatterplot of wt vs disp")
hist(wt, main="Histogram of wt")
boxplot(wt, main="Boxplot of wt")
# One figure in row 1 and two figures in row 2
attach(mtcars)
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))
hist(wt)
hist(mpg)
hist(disp)
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用ggplot并组合情节时,我没有得到输出.