On Mon, 20 Feb 2006, Ed Merkle wrote:
Dear SavioRs,
I am doing some research where characters in different microsoft
fonts serve as experimental stimuli. Hence, in plot labels, I would
like to display the characters in specific microsoft fonts. I have
figured out how to display letters and numbers, but I am having
trouble with symbols such as capital delta. Before I go further, I
am using R 2.2.1 on Windows XP with everything in English. I am
trying to save my plot as a windows metafile.
To display different characters in verdana, for example, I first edit
the Rdevga file so that it contains verdana. I can then get verdana
letters and numbers on the plot using a text() command. Things
within an expression() command, however, are not displayed in the
desired font. For example,
No, they are *always* displayed in font 5, as the Rdevga file actually
says. Verdana is not a mathematical font, and what you are looking for is
the Greek letter Delta, not the mathematical symbol.
windows()
plot(rnorm(15),rnorm(15))
text(0,0,expression(Delta),font=10)
displays a capital delta, but it is not in font #10 within Rdevga. I
can get characters that have one of the first 255 ascii codes
Hmm, there are only 128 ASCII codes. I guess you mean you are in CP1252
aka WinAnsi, the Windows approximation to ISO Latin-1, and so can only
access the (somewhat less than) 256 glyphs of that charset.
using
chars8bit() in the sfsmisc package. One example is the division sign:
text(0,0.2,chars8bit(247),font=10)
You don't need that: the standard octal and hex escapes work. But if you
want to draw symbols you should probably be using points() and pch=.
E.g.
points(0, 0.2, font=10, pch=247)
I have not been able to display other symbols in microsoft fonts,
however. Is this possible to do in R? All replies are appreciated.
Yes, but only by switching to a Greek locale. For example
Sys.setlocale(LC_CTYPE, greek)
plot(1:10)
text(8,2, \xC4, font=10)
and that only on an NT-based version of Windows and the R-devel version of
R.
It's easier on Unix-alikes in a UTF-8 locale, as then you can use Unicode
escapes like \u0394. But Windows does not have UTF-8 locales (although
one day R may fake them -- actually internally it already can but there is
no I/O support). There you could also do
text(8, 2, \u0394)
points(5, 7, font=4, pch=0x0394)
at least if you have fonts which support Greek.
--
Brian D. Ripley, [EMAIL PROTECTED]
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax: +44 1865 272595
__
R-help@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