Adjust the aspect ratio of the graph in R

I would like to have several subplots in a row in the plot. However, the evaluation of each subtask is narrow. How to adjust the compression ratio so that each subtitle becomes wider? Thank!alt text

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")
}
+3
source share
1 answer

You can make the device wider (X11, windows, pdf or something suitable for your system).

 X11(15, 7)
 par(mfrow=c(1,3)) 
 plot(density(rnorm(1000)))

etc..

You can also change the fields 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..

+4
source

Source: https://habr.com/ru/post/1776135/


All Articles