I\'d like to create latex-style math in plot titles in R. The plotmath tools have a useful but limited subset of expressions they can display, and use non-latex syntax and
You may want to check out the tikzDevice package (or take a look at its vignette first), which provides a natural way to write LaTeX math in R graphics.
I also have a simple example here.
And here is another example:
library(tikzDevice)
library(ggplot2)
tikz('math.tex', standAlone = TRUE, width = 4, height = 4)
qplot(1:10, 1:10,
main = '$\\mathrm{d} \\mathbf{x} = a [\\theta - \\mathbf{x}] \\mathrm{d} t$')
dev.off()
which produces this if you run pdflatex math.tex
:
You should edit your question rather than putting sub-comments (I'll see what I can do about the box.). I sometimes find that bquote only reaches down so deep and that you need to use substitute
. This works:
lambda <- 4
plot(1:10,1:10)
mtext(substitute(paste(d*bolditalic(x)[italic(t)] ==
alpha*group("[", (theta - bolditalic(x)[italic(t)] )*d*italic(t) +
lambda, "]") * d * italic(B)[italic(t)] ), list(lambda=lambda)),
line=2.25,cex=2)
It also works with ggplot and the title placement looks a lot better:
qplot(1:10, 1:10) + opts(title=substitute(paste(d*bolditalic(x)[italic(t)] ==
alpha*(theta - bolditalic(x)[italic(t)] )*d*italic(t) +
lambda * d * italic(B)[italic(t)] ), list(lambda=lambda)),
line=2.25,cex=2)
The "d" is "square" at least as I understand your meaning after referring to a set of Latex examples online at:
http://www.personal.ceu.hu/tex/cookbook.html
(I thought you wanted the http://en.wikipedia.org/wiki/D%27Alembert_operator and was not able to find that yet.)