在这种情况下,plotmath 无法强制调用表达式列表。
> cs <- c(bquote(theta == .(a)),bquote(theta == .(a)))
> cs
[[1]]
theta == 123
[[2]]
theta == 123
> sapply(cs, class)
[1] "call" "call"
如果您自己强制表达,您可以使这项工作:
> c(as.expression(bquote(theta == .(a))), as.expression(bquote(theta == .(a))))
expression(theta == 123, theta == 123)
> plot(1,1)
> legend('bottomleft',legend= c(as.expression(bquote(theta == .(a))),
+ as.expression(bquote(theta == .(a)))))
另一种方法是使用以下命令强制调用表达式的原始列表sapply
:
plot(1,1)
legend("bottomleft",
sapply(c(bquote(theta == .(a)), bquote(theta == .(a))), as.expression))