Bold Face in Plot
On Mon, 2 Mar 2009, Rau, Roland wrote:
Dear all,
I am trying to plot some text in bold face which works fine:
plot(0:1,0:1,type="n")
text(x=0.5, y=0.5, labels=expression(bold("the-actual-string")))
Now when I try to do the following, the displayed text reads thestring:
thestring <- "the-actual-string"
plot(0:1,0:1,type="n")
text(x=0.5, y=0.5, labels=expression(bold(thestring)))
See ?substitute (or its wrapper bquote) E.g.
lab <- substitute(bold(thestring), list(thestring=thestring)) text(x=0.5, y=0.5, labels=lab)
But, why are you setting plain text as an expression? The better way to do this is thestring <- "the-actual-string" plot(0:1,0:1,type="n") text(x=0.5, y=0.5, labels=thestring, font=2) See ?par (and ?text). There are subtle differences (e.g. how the baslines are aligned), and using plotmath when you do not need it will get you encountering those differences.
Can someone tell me what I am doing wrong? I assume it is rather simple
but I am stuck somehow.
Thanks in advance,
Roland
P.S. I tried it using ("ancient") R 2.7.0 on Windows32 and version 2.8.1
on GNU/Linux (Ubuntu 8.10).
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