about x- or y-axis

95 views
Skip to first unread message

lily li

unread,
May 16, 2017, 6:46:38 PM5/16/17
to ggp...@googlegroups.com
Hi ggplot2 users,

How to have superscript in x- or y-axis? For example, R2 in the x-axis. I tried various ways, but it didn't work. Thanks for your help.

+xlab(expression(paste('R^{2}')))

Ben Bolker

unread,
May 16, 2017, 7:03:50 PM5/16/17
to ggp...@googlegroups.com

dd <- data.frame(x=1:4,y=1:4)
ggplot(dd,aes(x,y))+geom_point()+labs(x=expression(R^2))
> --
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ggplot2+u...@googlegroups.com
> <mailto:ggplot2+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages