Italic greek letters / latex-style math in plot titles

后端 未结 2 999
陌清茗
陌清茗 2020-12-09 00:50

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

2条回答
  •  情书的邮戳
    2020-12-09 01:14

    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:

    latex math in ggplot2

提交回复
热议问题