[R] Weird blank spacing in plot title when using \n and plotmath

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat May 6 09:35:32 CEST 2006


This is only 'wierd' if you expect plotmath to understand how '\n' will be 
rendered.  Where do you see that documented?

In reality plotmath is computing the width of your string from the 
printable characters: see plotmath.c:RenderStr.

If you compare your example with

plot(1:10, main=expression(paste("ExposureTemp (", degree*F, ")")))

You will see that the final part is in exactly the same place, and also 
that your version is not centred vertically.

On Fri, 5 May 2006, Dav Aren wrote:

> Dear R-helpers,
>
>  I have been using \n in my plot titles to split long titles into two lines.  I recently tried combining \n and plotmath which still gives me two lines for the title but also a weird blank spacing.  A simple example is as follows:
>
> plot(1:10, main=expression(paste("Exposure\nTemp (", degree*F, ")")))
>
> Is there something I'm missing to close the spacing.  I have searched the R-help archives to no avail.  I am using R-2.3.0 with Windows XP.
>
> Thank you in advance for any help.
>
> D. Arenas

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list