斜体希腊字母/乳胶样式数学在剧情标题 [英] Italic greek letters / latex-style math in plot titles
问题描述
我想在R.的绘图标题中创建乳胶样式的数学。 plotmath工具有一个有用但有限的表达式子集,它们可以显示,并使用非乳胶语法和样式。
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 style.
例如,我打印等式$ \mathrm {d} \mathbf {x} = a [\theta - \mathbf {x }] \mathrm {d} t $在绘图的标题,并仍然评估某些变量的值。最好的解决方案是非常麻烦:
For instance, I would like to print the equation $\mathrm{d} \mathbf{x} = a [\theta - \mathbf{x}] \mathrm{d} t$ in the title of the plot, and still evaluate the value of certain variables. The best solution I have is the very cumbersome:
lambda <- 4
plot(1:10,1:10)
mtext(bquote(paste(d*bolditalic(x)[italic(t)] == alpha*(theta - bolditalic(x)[italic(t)] )*d*italic(t) + .(lambda) * d * italic(B)[italic(t)] )), line=2.25,cex=2)
或
require(ggplot2)
qplot(1:10, 1:10) + opts(title=bquote(paste(d*bolditalic(x)[italic(t)] == alpha*(theta - bolditalic(x)[italic(t)] )*d*italic(t) + .(lambda) * d * italic(B)[italic(t)] )), line=2.25,cex=2)
这个问题几乎解决了这个问题,但我松了bquote显示变量数值的能力(在我的例子中为lambda)。有没有办法组合这些,所以我可以有斜体的希腊字母(变量的标准格式,例如由tex做)和评估在特定的值?
This question almost solves this, but I loose the ability of bquote to display the numerical value of a variable (lambda in my example). Is there a way to combine these so I can have italic greek letters (the standard format for variables, e.g. as done by tex) and evaluate at specific values?
有没有更好的方法,我可以简单的写tex语法的方程式,并将它们添加到我的图形?
Is there a much better way where I can simple write tex-syntax for equations and add them to my graphs?
推荐答案
您可以查看 tikzDevice
包装(或查看
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.
我也有
这里是另一个例子:
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()
如果运行 pdflatex math .tex
:
这篇关于斜体希腊字母/乳胶样式数学在剧情标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!