Reputation: 99556
I would like to have several subplots in a row in a plot. However the apprearance of each subplot is narrow. How can I adjust the aspect ratio so that each subplot will become wider? Thanks!
par(mfrow=c(1,3))
for (i in 1:3){
dest=density(out[,i])
hist(out[,i], xlim=range(dest$x),xlab=paste("x[",i,"]"),ylab="density", main="", prob=TRUE)
lines(dest,col="red")
}
Upvotes: 3
Views: 7019
Reputation: 29525
You could make the device wider (X11, windows, pdf, or whatever is appropriate for your system).
X11(15, 7)
par(mfrow=c(1,3))
plot(density(rnorm(1000)))
etc.
You could also change the margins if you cannot change the device.
mar <- par("mar"); mar[c(2, 4)] <- 0
par(mfrow=c(1,3), mar = mar)
plot(density(rnorm(1000)))
plot(density(rnorm(1000)))
etc.
Upvotes: 4