Perhaps:
txt <- list(A=bquote(a == .(a)~'%'), B=bquote(b==.(b)~km^2))
plot(c(0,100), c(0,100), xaxs="i", yaxs="i",
type="n")
text(95-cumsum(strheight(txt)), 95-cumsum(strheight(txt)), parse(text=txt))
On 21/02/2008, B?lint Cz?cz <czucz at botanika.hu>
wrote:> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paran?-Brasil
25? 25' 40" S 49? 16' 22" O