[R] Degree symbol as axis label superscript

ani jaya g@@@uu| @end|ng |rom gm@||@com
Wed Dec 1 02:59:03 CET 2021


one of my solution :

text(x,y,"\u00B0C", cex=1.1, font=2)

it will produce "°C"

text(x,y,"\u00B3C", cex=1.1, font=2)
it will produce "superscript(3)C"

so basically change the character after the "\u00B..." will produce
the superscript.

Best, Ani

On Wed, Dec 1, 2021 at 4:05 AM Rich Shepard <rshepard using appl-ecosys.com> wrote:
>
> I want to present the temperature on the Y-axis label as 'Water Temperature
> (oC)' with the degree symbol as a superscript.
>
> My web search found a couple of methods; one put the entire example string
> in the axis label, the other is close, but still incorrect.
>
> Source example:
> #define expression with superscript
> x_expression <- expression(x^3 ~ variable ~ label)
> # The example axis label is:
> 'X3 variable label' (with the 3 as a superscript)
>
> My use:
> # Set degree symbol as superscript in plot's y axis:
> y_expression <- expression(^o ~ C)
>
> R's error message:
> Error in source("../scripts/all_temp_plots.r") :
>    ../scripts/all_temp_plots.r:10:28: unexpected '^'
> 9: # Set degree symbol as superscript in plot's y axis:
> 10: y_expression <- expression(^
>                                 ^
>
> What is the proper way to display a degree symbol in a plot's axis label?
>
> Rich
>
> ______________________________________________
> 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.



More information about the R-help mailing list