Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Save row multi-diagram to PDF in R without 1:1 ratio

$
0
0

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:

enter image description here

While I want each diagram to be square and the final image not to have a 1:1 ratio:

enter image description here


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:

enter image description here

How can I achieve this (possibly without using external libraries, but simple basic default R packages)?


Viewing all articles
Browse latest Browse all 201839

Trending Articles