[R] Plotmath, sweave and lattice graphics interaction problem

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Aug 28 19:10:27 CEST 2009

Dear List,

I have hit this problem with using a plotmath expression in an axis
label on a lattice plot I'm including in a Sweave document. The actual
document is far too long and boring (unless you are interested in the
hydrochemistry of upland lakes) to include here, but the following
minimal example reproduces the problem; basically, the PDF produced by
Sweave has missing characters in the plotmath label whilst the eps file

Here is the minimal Rnw document:



\author{Gavin Simpson}


dat <- data.frame(A = runif(10), B = runif(10))
print(xyplot(A ~ B, data = dat,
             ylab = expression(H^"+" ~ (mu*eq ~ L^"-1"))))


Note the ylab expression:

ylab = expression(H^"+" ~ (mu*eq ~ L^"-1"))

this produces a ylab like H+ (mueq L-1) when run interactively and on
the eps file, but the pdf file is missing the parentheses and the mu
(micro) symbol.

R session info:

> sessionInfo()
R version 2.9.1 Patched (2009-08-07 r49104) 


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

other attached packages:
[1] lattice_0.17-25

loaded via a namespace (and not attached):
[1] grid_2.9.1

So I'm running this in a UTF-8 locale. Is it this that is causing the
problem? Any suggestions as to how to proceed?

Thanks in advance,


 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk

More information about the R-help mailing list