Superscript R squared for legend

后端 未结 2 1624
悲哀的现实
悲哀的现实 2021-02-09 13:38

I want to write a R-squared term for my legend but I do not know how. Could someone help me please? My legend syntax is:

legend(2,10, c(\"BW (MPE=3%, R-squared=0         


        
2条回答
  •  佛祖请我去吃肉
    2021-02-09 13:50

    It will work if you combine bquote and as.expression:

    plot(1:10)
    legend(2, 10, c(as.expression(bquote("BW (MPE = 3%," ~ R^2 ~ "= 0.77)")),
                    as.expression(bquote("MY (MPE = 5%," ~ R^2 ~ "= 0.80)"))), 
           pch=c(2,3))
    

    enter image description here

提交回复
热议问题