title: Trouble with margins & plot sizes in multiple figure plot in pdf
body: <p>I'm trying to make a lot of plots and dump them to a pdf.  Some of the plots naturally go together, so I'd like them to be on the same page of the pdf.  However, either the dimensions get distorted, or the titles and x-axis labels don't show up.  Does anyone know how to fix this?  </p>
  
  <p>Here is an example:  </p>
  
  <pre><code>set.seed(1)
  x &lt;- runif(100)
  
  pdf(file="My pdf.pdf", paper="letter")
    par(mfrow=c(2,1))                     # squished
    hist(x, freq=FALSE)
    lines(density(x))
    qqnorm(x)
  dev.off()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/TSNE7.png" alt="enter image description here"></p>
  
  <pre><code>pdf(file="My pdf.pdf", paper="letter")
    par(mfrow=c(2,1), pin=c(3,3))         # no titles, etc.
    hist(x, freq=FALSE)
    lines(density(x))
    qqnorm(x)
  dev.off()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/OETd7.png" alt="enter image description here"></p>
  
  <pre><code>pdf(file="My pdf.pdf", paper="letter")
    par(mfrow=c(2,1), pin=c(3,3), mar=c(4,2,2,1))  # squished again
    hist(x, freq=FALSE)
    lines(density(x))
    qqnorm(x)
  dev.off()
  
  pdf(file="My pdf.pdf", paper="letter")
    par(mfrow=c(2,1), mar=c(4,2,2,1), pin=c(3,3))  # now titles but overlapping
    hist(x, freq=FALSE)
    lines(density(x))
    qqnorm(x)
  dev.off()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/XsYFk.png" alt="enter image description here"></p>
  
  <p>What I'd like is not just code to do this, but to understand how this works.  For example, why does changing the order of the arguments in the last two versions make so much difference.  Note that, I will have differing numbers of plots to go together (sometimes 2, 4 or 8) on a page, even though I only demonstrate the simplest case here.  Some code that will scale plots nicely automatically might be nice, if it exists.  </p>