Re: [R] greek symbols using pch

From: Prof Brian Ripley <>
Date: Tue 11 Oct 2005 - 17:36:08 EST

This is now well off the topic of the subject line, but I am afraid some misinformation has been propagated (and that is the `bug').

There _are_ bugs in the code shown: the postscript fonts support 32:255, not 1:256, and pch:0:31 are not taken from the font. It seems an uninformed modification of the code in ?postscript.

What locale are you in? That's something gives and the posting guide asks for (because it often matters).

The code given works (albeit with warnings) in an 8-bit locale, but it often will not work in a multi-byte locale. In particular it does not work in a UTF-8 locale for a postcript() device.

The help page for points() does point out clearly

      In a multi-byte locale
      such as UTF-8, numeric values of \code{pch} greater than or equal to
      32 specify a Unicode code point.

Thus in UTF-8, pch=167 should be interpreted as a Unicode code point, and that is not a Greek symbol.

The problem for postscript() (and X11()) is that the standard font=5 is not encoded in the locale's encoding but Adobe Symbol, so supplying Unicode characters is unsupported.

I think R is working as documented here, but the piece of documentation about font=5 is in a different place (it is driver-specific).

Internationalization support for the postscript() driver is work in progress (more features will appear in 2.3.0), but at present all you can expect to work in a UTF-8 locale are ISO Latin-1 characters, and symbols via plotmath.

(I am aware of a few things that are not quite right in the Unicode support: some are being fixed for 2.3.0.)

On Tue, 11 Oct 2005, ecatchpole wrote:

> On 11/10/05 01:12,  Earl F. Glynn wrote,:

>> "FISCHER, Matthew" <> wrote in message
>>> In a plot, can I specify pch to be a greek symbol? (I looked at
>>> show.pch() in the Hmisc package but couldn't see the right symbols in
>> there).
>>> If not, I guess I can get around this using text(x,y,expression()).
>> I'm not sure where this is explained very well. Having ?font give a clue
>> about this would be nice.
>> Use font=5, the symbol font. To see what's in font=5:
>> par(font=5, las=1)
>> plot(0:15,0:15,type="n",ylim=c(15,0),
>> main="Symbols in Font=5",
>> xlab="", ylab="",xaxt="n", yaxt="n")
>> axis(BOTTOM<-1, at=0:15, 1:16)
>> axis(LEFT <-2, at=0:15)
>> abline(v=0.5 + 0:14,
>> h=0.5 + 0:14, col="grey", lty="dotted")
>> # pch index of any cell is 16*row + column
>> for(i in 0:255)
>> {
>> x <- i %%16;
>> y <- i %/% 16;
>> points(x,y,pch=i+1)
>> }
> When I execute this code, I get a calligraphic R or P occurring with all
> of the nifty characters, e.g. \clubsuit. For example
> par(font=5, las=1)
> plot(0:1, 0:1, type="n")
> points(.5, .5, pch=167)
> This occurs on screen and in postscript() output. And with R2.1.0 and
> R2.2.0. Is this a bug?
> Ted.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list PLEASE do read the posting guide! Received on Tue Oct 11 17:42:08 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:41 EST