Re: [R] Subscript in axis label

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Sun, 03 Jun 2007 13:17:12 +0200

Tobias Verbeke wrote:

> pm509_at_york.ac.uk wrote:
>   

>> Dear R help list members,
>>
>> I am experiencing difficulty in trying to generate a subscript '2' in an
>> axis label. Although I can get the '2' into a subscript using expression(),
>> R then forces me to leave at least one space between the '2' and the
>> following character. My label is supposed to read 'N2O concentration
>> (ppm)', and the space between the '2' and the 'O' makes it look rather
>> inelegant! My code is the following (the comments in it are there to stop
>> me forgetting what I have done, I am new to R):
>>
>> postscript(file="/Users/patrickmartin/Documents/York Innova
>> Precision/N2Oinnova.eps", horizontal=FALSE, onefile=FALSE, height=4,
>> width=5, pointsize=10)
>>
>>> plot(n2o, lty=0, las=1, xlab="Time", ylab=expression(N[2]~"O
>>> concentration (ppm)")) points(n2o, pch=16) # suppresses line but adds
>>> points dev.off() # turns postscript device off again
>>>
>
> Is this better
>
> plot(1:10, ylab = expression(paste(N[2],"O concentration (ppm)",
>                               sep = "")))
>   

Or,

plot(1:10, ylab = expression(N[2]*O~"concentration (ppm)"))

(because of the "~", you can even do away with "expression()", but I think that would be overly sneaky.)



R-help_at_stat.math.ethz.ch 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. Received on Sun 03 Jun 2007 - 11:26:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 03 Jun 2007 - 11:31:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.