[R] GGPLOT: Superscript text in body of plot
Jeff Newmiller
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sat Jan 29 20:58:19 CET 2022
a) ?plotmath, e.g. expression( R^2 * "=0.23" )
b) "carrot" is a root vegetable. "carat" is a jewelers measure. "caret" is a ^.
On January 29, 2022 11:32:10 AM PST, "Sorkin, John" <jsorkin using som.umaryland.edu> wrote:
>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 using 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.
--
Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list