[R] Degree symbol as axis label superscript

Andrew Simmons @kw@|mmo @end|ng |rom gm@||@com
Tue Nov 30 20:33:47 CET 2021


Excuse my brevity, but take a look at ?plotmath

It has tons of tips for making pretty labels

On Tue, Nov 30, 2021, 14:05 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list