[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
doesn't.
Here is the minimal Rnw document:
\documentclass[a4paper,12pt]{article}
\usepackage{graphicx,xspace}
\usepackage[utf8]{inputenc}
\usepackage[left=1.5cm,top=2cm,bottom=2cm,right=1.5cm]{geometry}
\usepackage{/home/gavin/R/2.9-patched/build/share/texmf/Sweave}
\setkeys{Gin}{width=1\textwidth}
\begin{document}
\title{FOO}
\author{Gavin Simpson}
\maketitle
<<fig=true>>=
require(lattice)
dat <- data.frame(A = runif(10), B = runif(10))
print(xyplot(A ~ B, data = dat,
ylab = expression(H^"+" ~ (mu*eq ~ L^"-1"))))
@
\end{document}
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)
x86_64-unknown-linux-gnu
locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C
attached base packages:
[1] tools stats graphics grDevices utils datasets
methods
[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,
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
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