[R] How to show the symbol of Angstrom ?

Paul Murrell p.murrell at auckland.ac.nz
Tue Sep 14 02:39:32 CEST 2004


Hi


xiang li wrote:
> Also, I am wondering if there is any source where the expressions of 
> many symbols are collected.
> Thanks you very much!!!


(Assuming you mean draw the angstrom symbol on a plot ...)

There are several ways:

(i) Specify the character code in octal.  Assuming ISO Latin 1 encoding, 
something like ...
   plot(1, type="n")
   text(1, 1, "\305")
... or ...
   grid.newpage()
   grid.text("\305")
... should work.  That should be ok on default setups for Windows and 
Unix.  On the Mac it might have to be "\201" (untested)  See, e.g., 
http://czyborra.com/charsets/iso8859.html#ISO-8859-1 (Unix)
http://www.microsoft.com/typography/unicode/1252.gif (Windows)
http://kodeks.uni-bamberg.de/Computer/CodePages/MacStd.htm (Mac)
for other standard "symbols".

(ii) Use a mathematical expression.  This won't look as good because the 
ring and the A are not a single coherent glyph, but it should work 
"everywhere" ...
   plot(1, type="n")
   text(1, 1, expression(ring(A)))
... or ...
   grid.newpage()
   grid.text(expression(ring(A)))
... demo(plotmath) shows the range of things you can do with this approach.

(iii) Use a hershey font (again, should work on all platforms and 
encodings) ...
   plot(1, type="n")
   text(1, 1, "\\oA", vfont=c("sans serif", "plain"))
... or ...
   grid.newpage()
   grid.text("\\oA", gp=gpar(fontfamily="HersheySans"))
... demo(Hershey) shows the symbols available with this approach.

Hope that helps.

Paul
-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list