[R] How to draw a per mille symbol?
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed Sep 20 12:43:28 CEST 2006
On Tue, 2006-09-19 at 17:53 +0100, Prof Brian Ripley wrote:
> On Tue, 19 Sep 2006, Gavin Simpson wrote:
>
> > Dear list,
> >
> > Following advice posted to this list a while back by Prof Ripley [1], I
> > have been trying to draw a per mille character [2] in an axis label.
> >
> > This should give the correct character:
> >
> > plot(1:10, ylab = "\u2030")
> >
> > but all I get is '"S'. I'm running linux (FC5) and have fonts installed
> > that have the correct character (viewed in the Gnome character map at
> > least).
>
> On what device? If X11, this is almost always a font selection issue.
> Unicode support in X11 fonts is a complex issue that seems to vary with
> every minor update.
Yes, this was an X11 device.
>
> > I have also tried plotting to a pdf device with a font family that the
> > character map tool shows I have a per mille glyph for, e.g.:
>
> What does character map have to do with postscript fonts?
Given your comment, nothing. You've probably guessed I know very little
about fonts, and had naively assumed that a font of the same name as a
name displayed by postscriptFonts() or pdfFonts(), which showed a per
mille sign in the character map tool in Gnome, were one and the same
thing.
>
> > pdf("~/tmp/test_per_mille.pdf", paper = "a4", family = "URWBookman")
> > plot(1:10, ylab = "\u2030")
> > dev.off()
> >
> > But all I get here is a period or a dot-like symbol.
>
> But see the article in R-news 2006-2 about this. All we can do for PDF is
> to use an appropriate 8-bit font map, or a CJK font. It seems that e.g.
> encoding="CP1251" works, even for Helvetica.
>
Ok, thanks for this - I've now read this and think I understand the
issues and how to work with fonts in R a bit better now.
The ultimate aim was to be able to include relevant code in a Sweave
document. I'm not aware of a way to pass extra instructions to the pdf
generator code in Sweave, so the solution will involve generating the
pdf within embedded R code directly and inserting the figure manually
into the the document. Is my thinking correct here?
Thanks again for answering my questions, Prof. Ripley.
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [t] +44 (0)20 7679 0522
ECRC & ENSIS, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list