Hello, Here is a way.
ggplot(jjdata, aes(x=x, y=y))+ geom_point(size=2,shape=1)+ geom_text(x=3, y=7.5, label=expression(paste(R^2 == '0.23'))) Hope this helps, Rui Barradas Às 19:32 de 29/01/2022, Sorkin, John escreveu:
Can you help me create text that has a superscript 2? I am trying to add text within the body of a plot created with ggplot. I what the text to R-squared = 0.23. I want R-squared to be shown in standard notation, i.e. capital R followed by a super-script 2 and then =0.23 as standard (i.e. non-superscripted text). I have tried the follow, but it does not work: jjdata <- data.frame(x=1:10,y=1:10) jjdata ggplot(jjdata, aes(x=x, y=y))+ geom_point(size=2,shape=1)+ geom_text(x=3, y=7.5, label='R^2=0.23') The result I get follows the text of the label argument perfectly. The carrot (^) is included in the printed text; it is not interpreted as a command to set the 2 as a superscript. How do I make the 2 into a superscript? Thank you, Joh ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.