[R] Title

David Scott d.scott at auckland.ac.nz
Tue Feb 8 21:25:48 CET 2011


On 9/02/2011 6:25 a.m., David Winsemius wrote:
>
> On Feb 8, 2011, at 11:43 AM, kateF87 wrote:
>
>>
>> I have a relatively simple question.
>>
>> I am trying to post a title to a plot using a symbol and multiple
>> lines.
>> Right now I have:
>>
>> title(main = c('Hazard Ratio for women with score', expression('>='),
>> 'Across /nQuintiles of Activity')
>
> I am going to anticipate the next question, which I assume to be how
> to insert a value after the ">=" sign:
>
>   >  b=5
>   >  plot(1,1)
>   >  title(main = bquote(atop(paste("Hazard Ratio for women with score",
> "">=.(b)) , "Across Quintiles of Activity") ) )
>

Wow, where did you get that idea from! In my mind atop had always been 
for use in such things as the expression for a combination, basically a 
fraction without the dividing line between numerator and denominator. To 
use it to put whole lines of text on top of each other is ... creative!

I was going to offer the conventional advice which is to use mtext 
because of the restriction in plotmath that \n is not allowed:

"Control characters (e.g. \n) are not interpreted in character strings 
in plotmath, unlike normal plotting."

But atop works as you suggest. A very useful trick, because mtext with 
multiple lines can take time to get right. It does offer a bit more 
control over line spacing which could be a concern with atop.

David Scott





-- 
_________________________________________________________________
David Scott	Department of Statistics
		The University of Auckland, PB 92019
		Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:	d.scott at auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics



More information about the R-help mailing list