multiple bquote items in legend of an R plot

后端 未结 2 789

Following works, (copy & paste into R)

a=123
plot(1,1)
legend(\'bottomleft\',legend=bquote(theta == .(a)))

I want to have multiple item

2条回答
  •  一个人的身影
    2021-01-04 11:44

    To coerce the original list of calls to expressions it is not necessary to use sapply(). It suffices to use as.expression() only for one of the components within the c() construct:

    plot(1,1)
    legend("bottomleft", 
           c(as.expression(bquote(theta == .(a))), bquote(theta == .(a))))
    

    c() will then automatically coerce the whole list, to the expression class.

提交回复
热议问题