R:在情节图例中使用表达式 [英] R: using expression in plot legends
本文介绍了R:在情节图例中使用表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 R 中使用 legend
函数.我希望标签读取 $\alpha = 1, \beta = 2$,所以我尝试使用
I'm trying to use the legend
function in R. I want the label to read $\alpha = 1, \beta = 2$, so I tried using
legend("topleft", c(expression(alpha = 1, beta = 2)))
但这并没有奏效.有什么建议吗?
But that did not do the trick. Any advice?
如果我想让我的标签读取 $Gamma(\alpha = 1, \beta = 2)$ 怎么办?我试过了
What if I wanted my label to read $Gamma(\alpha = 1, \beta = 2)$? I tried
legend("topleft", c(paste("Gamma( ", expression(alpha = 1, beta = 2))))
推荐答案
我们可以把所有东西都放在表达式
本身
We can place everything within the expression
itself
plot(1)
legend("topleft", expression(alpha~"= 1, "~beta~" = 2"))
如果我们需要Gamma(
legend("topleft", expression(Gamma*"("*alpha~"= 1, "~beta~" = 2)"))
如果我们需要Gamma
legend("topleft", expression("Gamma("*alpha~"= 1, "~beta~" = 2)"))
这篇关于R:在情节图例中使用表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文