[R] linebreaks in mathplot

Bálint Czúcz czucz at botanika.hu
Thu Feb 21 14:29:36 CET 2008


Dear HelpeRs,

I would like to do sg similar to:

plot(c(0,100), c(0,100), xaxs="i", yaxs="i", type="n")
txt <- paste("a =", a, "%\n b =", b, " km2", sep="")
text(95, 95, txt, adj=c(1,1))

just with the "km2" formatted with 2 in a superscript.
I thought

txt <- substitute("a = "*a*" %\n b ="*b*" km"*phantom()^2, list(a=a,b=b))

would do it. However it does not work.
Is it possible to formulate "multi-line" expressions in plotmath? What
is the trick?

Or I should break txt into separate lines, and place the lines
independently using text and strheight()?

Thanks,
Bálint

--
> sessionInfo()
R version 2.6.1 (2007-11-26)
i386-pc-mingw32

locale:
LC_COLLATE=Hungarian_Hungary.1250;LC_CTYPE=Hungarian_Hungary.1250;LC_MONETARY=Hungarian_Hungary.1250;LC_NUMERIC=C;LC_TIME=Hungarian_Hungary.1250

attached base packages:
[1] grDevices graphics  stats     datasets  utils     methods   base

other attached packages:
[1] JGR_1.5-8    iplots_1.1-1 JavaGD_0.4-3 rJava_0.5-1

-- 
Bálint Czúcz
Institute of Ecology and Botany of the Hungarian Academy of Sciences
H-2163 Vácrátót, Alkotmány u. 2-4. HUNGARY
Tel: +36 28 360122/157 +36 70 7034692



More information about the R-help mailing list