[R] plot ᵒ C in graph axis label

baptiste auguie
Fri, 02 Oct 2009 06:58:59 -0000

Hi,

You cannot start with a "*" in expression(). Try this,

 plot(x~y,ylab=expression(~degree~C))

or even, as a short-cut,

 plot(x~y,ylab=~degree~C)

HTH,

baptiste

2009/10/2 e-letter <inpost at gmail.com>:
> Readers,
>
> I have tried to use a plotmath command to add the temperature degree
> sign (i.e. ? C) to the axis label of a graph:
>
>> x<-(1:10)
>> y<-(200:191)
>> plot(x~y,ylab=expression(*degree~C))
> Error: syntax error, unexpected '*', expecting ',' in
> "plot(x~y,ylab=expression(*"
>
> According to plotmath manual, the syntax is '*degree' and I am able
to
> use this command when a number precedes the asterisk (e.g.
> ylab=expression(0*degree~C)). But I want to omit the need for a number
> before the degree sign. Any advice please?
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>