[R] font=5 (Was: greek symbols using pch)

ecatchpole E.Catchpole at adfa.edu.au
Tue Oct 11 10:44:40 CEST 2005


Thanks for that. Very instructive, and much appreciated.

And sorry, yes, I strayed well off the original topic. The Greek symbols 
  come out fine with font=5 in my locale,
Locale:
LC_CTYPE=en_GB.UTF-8;
LC_NUMERIC=C;
LC_TIME=en_GB.UTF-8;

I was interested in some of the other nice characters, for example 
\infty and \partial, that appear in the table, but with a calligraphic R 
attached to them. But plotmath() works fine, so I'm happy.

Ted.

On 11/10/05 17:36,  Prof Brian Ripley wrote,:
> 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 bug.report() 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" <mjf at ansto.gov.au> wrote in message
>>> news:283982AD9F3CD211B3AC00A0C983032F11443674 at paradise.ansto.gov.au...
>>>
>>>>    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.
> 


-- 
Dr E.A. Catchpole
Visiting Fellow
Univ of New South Wales at ADFA, Canberra, Australia
and University of Kent, Canterbury, England
- www.ma.adfa.edu.au/~eac
- fax: +61 2 6268 8786		
- ph:  +61 2 6268 8895




More information about the R-help mailing list