[R] title and axis labels placement with layout

Daryl Morris darylm at uw.edu
Mon Oct 4 20:33:54 CEST 2010


  Hello,

I'm writing a set of functions which we will use with a bunch of 
different datasets.  The functions create a set of graphics pages, with 
each page split into an upper panel with plots and a lower panel with 
tables.  The plots part might have one plot, or might have multiple.  
I'm using layout() to split the region into a top part for plots and a 
bottom part for 2 tables side-by-side.  For the tables below, I'm using 
textplot() from the gplots package.  I'm trying to get it so that the 
layout of the full page looks exactly the same regardless of the plot.

My working test case creates a boxplot with a few groups on one page, 
and 6 boxplots each with 3 groups on another page.  R automatically 
scales the "cex" parameter such that, for example, the points are 
smaller on the more complicated plots.

I can live with different point sizes.  But, I want the tables to have 
the same size below.  After much trial and error, I determined that I 
had to set "cex" OUTSIDE of textplot in order to get the sizes of the 
tables to be the same across pages.

But, what I can't get to work are 2 things:
(1) the ylabel placement (horizontally) for the top plot depends on the 
graphics in a way that I can't figure out.  (I've tried setting 
cex,lheight and many combinations of padj, line using both the plot 
function itself and title, mtext functions after the plot call).
(2) I can't figure out how to put a title on the tables such that they 
end up in repeatable position.  Again, I've tried all the various 
options I tried in (1) here again.

One solution to (1) would be if I could place the label using a 
measurement rather than a line number.  (analogous to using par("mai") 
instead of par("mar"))
One solution to (2) would be that textplot include a "main" option.


thanks,
Daryl Morris
SCHARP, FHCRC, UW Biostatistics



More information about the R-help mailing list