[R] Mathematical annotation axis in lattice
Paul Hiemstra
p.hiemstra at geo.uu.nl
Tue Jul 7 17:50:18 CEST 2009
Hi Albart,
This bugged me also for quite some time. After some experiments the
following syntax worked best:
library(lattice)
a = 0.11
xyplot(1:10~10:11, xlab = as.expression(bquote(R^2~" equals "~.(a))))
With the combination of as.expression and bquote you can mix text, math
expression and the content of objects (in the case here of a). Read the
documentation of bquote for more details.
cheers,
Paul
Coster, Albart wrote:
> Dear list,
>
> making mathematical expressions in plots is not difficult: expression(phi[1]) for example. At this moment I am stuck in creating a vector of expressions:
>
> pos <- 1:10
> lab <- letters[pos]
>
> Now, I would like to create a vector of expressions which I could use for labeling the x-axis of a lattice plot.
>
> ll <- as.expression(paste(pos," phi[",lab,"]",sep = "")
>
> xyplot(1:10~11:10,scales = list(x = list(labels = ll,at = 1:10)))
>
> does not work. I read about the function substitute, but that did not solve it.
>
> Could you recommend me how I should do this?
>
> Thanks in advance,
>
> Albart Coster
>
> Wageningen Universiteit
> Netherlands
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +3130 274 3113 Mon-Tue
Phone: +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
More information about the R-help
mailing list