Italic greek letters / latex-style math in plot titles

后端 未结 2 987
陌清茗
陌清茗 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:20

    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)
    

    enter image description here

    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.)

提交回复
热议问题