Creating an Angstrom Symbol in IDL
QUESTION: How can I create an angstrom symbol in IDL to display on my graphics plot?
![]()
ANSWER: I could just give you the answer, but this was such a fun discussion in the IDL newsgroup, I thought I would give you a taste of how these things are usually hashed out. Here was my original answer to the question, which was asked by David Kennedy.
This is simple. Simply consult the table of octal values in the IDL documentation. (Octal values!? These people are trying to put money in my pocket!) You see that the octal value for the Angstrom symbol in Simplex Roman font (!3 for cognoscente) is 305. (Add the number in the column row to 10 times the row number, according to the documentation. Sigh...)
So, here it is:
XYOUTS, 0.5, 0.5, /Normal, CharSize=2.0, 'Symbol: ' + STRING("305B)
What, you had to look up how to write an octal number! It's, "number, like that.
If that is too confusing for you, you can resort to the perfectly simple:
angstrom = '!6!sA!r!u!9 %!6!n'
Now all you have to do is:
XYOUTS, 0.5, 0.5, /Normal, CharSize=2.0, 'Symbol: ' + angstrom
Hope this clears up any confusion. :-)
![]()
I got all kinds of e-mail about this. Here is what I wrote next.
As if I don't have problems enough on this newsgroup, now I am getting a slew of mail about angstrom symbols. Typical of the mail I am getting is this one from Dr. Watson (or someone like him, I can't remember):
Ok, if nobody else is going to do it, then I will: what the hell are you doing here? (angstrom = '<string-of-greek>') Please enlighten me.
It's elementary, my dear Watson. What I wrote was this:
angstrom = '!6!sA!r!u!9 %!6!n'
Take out your Geek to English dictionary. You can find it in Chapter 9 of the IDL User's Guide. This sentence is easily parsed:
!6 -- Complex Roman font, of course, what else could it be?
!s -- According to the dictionary it's "save position". This
means, well, it means... Well, skip this for now.
A -- Capital A, splendid, Watson!
!r -- "restore position". You see, you didn't need to worry about !s.
!u -- Shift to upper subscript. We're going to write something
above the A.
!9 -- special symbol font. We need a tiny circle.
% -- This is how you draw a tiny circle, Watson. Pay attention!
!6 -- Well, what did it mean *before* Watson!
!n -- Back to normal text level (from subscripting).
As I say, Watson, elementary!
![]()
Later I learned from Brian Handy at Montana State University that the easiest way to create an angstrom sign is to simply do this:
XYOUTS, 0.5, 0.5, /Normal, CharSize=2.0, 'Symbol: ' + STRING(197B)
Then I learned from Bill Thompson that this is just another way of writing the octal number "305B! So it is. :-(
The problem with this octal or decimal (or even hexadecimal 'C5'x) notation is that it won't work unless it is done in the Simplex Roman Font. So I think the correct formulation for the angstrom symbol is this:
angstrom = '!3' + STRING(197B) + '!X'
Finally, Stein Vidar Hagfors Haugan and Joe Gurman pointed out to us how to make this work in the PostScript hardware font. You must select the Adobe ISO Latin 1 font encoding with the ISOLATIN1 keyword to the DEVICE command after making the PostScript driver active. The ISO Latin 1 character set is wonderful for making all kinds of foreign characters: è, ¥, Ö, Niña, etc. All you have to do is find a table of values. (Don't look for it in the IDL documentation set, alas.) I found mine in the back of an HTML book.
The correct sequence of commands will look something like this:
thisDevice = !D.NAME SET_PLOT, 'PS' !P.FONT = 0 DEVICE, /ISOLATIN1 angstrom = STRING(197B) XYOUTS, 0.5, 0.5, /Normal, CharSize=2.0, 'Symbol: ' + angstrom !P.FONT = -1 SET_PLOT, thisDevice
Finally, Peter Mason suggested a way to make this work with hardware fonts on the IDL display. His suggestion was to "divide the sucker by 10 and write it as '(nm)'." Not a bad solution when you think about it! :-)
![]()
Copyright © 1997 David W. Fanning
Last Updated 31 January 1997
