Ggplot2 - annotated text with the inscription

I want to add the value of R ^ 2 to my plot. I passed the geom_text () label as follows:

geom_text(aes(x,y,label=caption),parse=T, data.frame(x=-2,y=80,caption=("R^2=0.43")))) 

but it is portrayed as = (R ^ 2.0.43). Any ideas?

+4
source share
1 answer

You want your title to be "R ^ 2 == 0.43". See the help page for plotmath . There he shows that == gives you equal.

EDIT:

To answer the comment after the question, you can use atop in the expression. "atop(R^2==0.43,p==0.763)" This works for two lines, but no more.

+8
source

Source: https://habr.com/ru/post/1368857/


All Articles