问题是我设法绘制了这个图:
写这个:
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)
现在,这正是我希望这两个图一起可视化的方式。我不想把它们分开。
但是我想将所有内容放在如下结构的右侧面板(2)中,这样我就可以在面板(1)上添加另一个图,而不会弄乱一切:
layout(matrix(c(1,2), nr=1, byrow = TRUE))
我该怎么做?
答案 0 :(得分:1)
如果我理解你,你只想这样做:
par(mfrow=c(1,2))
qqplot(...)
qqline(...)
hist(...)
lines(...)
对你所追求的东西的替代解释是将你拥有的所有东西放在第二面并将第一面留空(用于别的东西)。如果是这种情况,您可以使用screen
:
figs <- rbind(c(0, 0.5, 0, 1), # Screen1
c(0.5, 1, 0, 1), # Screen2
)
colnames(figs) <- c("W", "E", "S", "N")
rownames(figs) <- c("Screen1", "Screen2")
screenIDs <- split.screen(figs)
names(screenIDs) <- rownames(figs)
screen(screenIDs["Screen1"])
# Everything that should go on the left side goes here
screen(screenIDs["Screen2"])
# The current plots you have go here