Dav Aren
2006-May-06 04:36 UTC
[R] Weird blank spacing in plot title when using \n and plotmath
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 __________________________________________________ [[alternative HTML version deleted]]
Prof Brian Ripley
2006-May-06 07:35 UTC
[R] Weird blank spacing in plot title when using \n and plotmath
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