I am trying to generate a PDF image in R of three plots arranged in a row grid. This is what I tried:
pdf("fig.pdf")
par(mfrow=c(1,3))
plot(rnorm(100), rnorm(100), xlab="Something on X", ylab="Some on Y", main="This is it 1")
plot(rnorm(100), rnorm(100), xlab="Something on X", ylab="Some on Y", main="This is it 2")
plot(rnorm(100), rnorm(100), xlab="Something on X", ylab="Some on Y", main="This is it 3")
dev.off()
But it produces:
While I want each diagram to be square and the final image not to have a 1:1 ratio:
Attempts
I have tried:
pdf("fig.pdf", width = 3, height = 1)
But that generated errors when plotting each single diagram, complaining the size was not enough:
Error in plot.new() : figure margins too large
If I try:
par(mfrow=c(1,3), pty='s')
Then:
How can I achieve this (possibly without using external libraries, but simple basic default R packages)?