title: R, layout: How to determine the width of the parts of a plotting region in order to center a title?
body: <p>I would like to center a title with respect to a plot matrix (and not the overall plot) I created with this code:</p>
  
  <pre><code>d &lt;- 3
  d2 &lt;- d*d
  layout.mat &lt;- matrix(1:d2, byrow=TRUE, ncol=d) # plot matrix
  layout.mat &lt;- cbind(layout.mat, rep(0, d)) # space
  layout.mat &lt;- cbind(layout.mat, rep(d2+1, d)) # column on the right side
  wspace &lt;- 6*par("csi")*2.54 # width of the space in character height in cm
  wside &lt;- 3*par("csi")*2.54 # width of the right side in character height in cm
  layout(layout.mat, respect=TRUE, widths=c(rep(1, d), lcm(wspace), lcm(wside)))
  layout.show(d2+1)
  par(mar=rep(0, 4), oma=c(4,4,6,4))
  for(i in 1:d){
      for(j in 1:d){
          plot.new()
          plot.window(xlim=c(0,1), ylim=c(0,1))
          ll &lt;- par("usr")
          rect(ll[1], ll[3], ll[2], ll[4])
          text(0.5, 0.5, paste("i=",i,", j=",j,sep=""), cex=1.4)
      }
  }
  plot.new()
  plot.window(xlim=c(0,1), ylim=c(0,1))
  ll &lt;- par("usr")
  rect(ll[1], ll[3], ll[2], ll[4])
  text(0.5, 0.5, "side", cex=1.4)
  
  ## title
  mtext("This title should be centered according to the plot matrix", side=3,
        line=2, outer=TRUE, adj=0.5, at=0.5)
  </code></pre>
  
  <p>How can I determine (with given fixed distances <code>wspace</code> and <code>wside</code>) the width of plot region so that I can subtract <code>wspace+wside</code> from it to determine the width of the plot matrix? The ultimate goal is to determine a precise value for <code>adj</code> of <code>mtext</code> such that the title is centered above the plot matrix and not the overall plotting region.</p>