[R] title and axis labels placement with layout
Greg Snow
Greg.Snow at imail.org
Mon Oct 4 20:48:11 CEST 2010
You might want to look at the addtable2plot function in the plotrix package as an alternative for your tables.
For placing titles/labels/etc. look at the grconvertX and grconvertY functions for ways to get coordinates based on the device converted to other coordinate systems. You can use those with the text function (or others) to place a label at a fixed position on the device.
Another option is to include an empty plot area in the layout to place the titles/labels into.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Daryl Morris
> Sent: Monday, October 04, 2010 12:34 PM
> To: r-help at r-project.org
> Subject: [R] title and axis labels placement with layout
>
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list