问题
I have several plots that I want to combine them together and add a title to the combined plot, but somehow I cannot combine them using R. (using RStudio)
- Combine two residual plots plotted by using
plot(resid(lme))
where lme is a linear mixed model. - Combine two interaction plots plotted by using
interaction.plot(x1,x2,y)
where x1 and x2 are the two independent variables, and y is the dependent variable.
I tried to store the plots as variables and use grid.arrange
, but they cannot be stored into a variable (just produce the plot in the plot area).
i.e.
> int1 <- interaction.plot(data_pos_10$Day,data_pos_10$Drug,data_pos_10$Tumor.Volume,
+ xlab="Day",ylab="Tumor Volume",main="Interaction Plot Batch 10",
+ legend=F,
+ col=c("red","red","green","black","blue"),
+ lwd=2,
+ lty=c(1,2,3,4,5))
> int1
NULL
回答1:
Before you do your plotting code, run par(mcol=c(2,1))
to stack them vertically or par(mcol=c(1,2))
to stack them horizontally.
来源:https://stackoverflow.com/questions/22309739/combine-plots-in-r