The problem is that I managed to graph this:
by writing this:
par(mar=c(0,4,2,1)+.1)
shap <- shapiro.test(as.numeric(residuals.arima))$p.value
qqnorm(residuals.arima, main=c("Normal Q-Q Plot", paste("Shapiro p=", prettyNum(shap, digits = 2))))
qqline(residuals.arima)
op <- par(fig=c(.02,.5,.5,.98), new=TRUE)
hist(residuals.arima, breaks=22, probability=T,
col="grey", xlab="", ylab="", main="", axes=F)
lines(a,dnorm(a,mean(residuals.arima), sd(residuals.arima)), lty=1, col="darkblue", lwd=2)
box()
par(op)
Now, this is exactly the way I'd like the two plots to be visualized together. I do not want to split them up.
However I'd like to put everything in the right panel (2) of a structure like the following, so that I can add another plot on panel (1) without everything messing up:
layout(matrix(c(1,2), nr=1, byrow = TRUE))
How can I do this?