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). 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.: 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. I've tried this in R 2.4.0 alpha [4] and R 2.5.0 to be [4] as my self-compiled R 2.3.1-patched dies when plotting Unicode characters (fixed in 2.4.0 alpha and above [3]) Can anyone point me in the right direction to get this working? TIA, G [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48709.html [2] like a "%" but with 2 circles at the bottom not one, see http://en.wikipedia.org/wiki/Permille [3] see thread at http://article.gmane.org/gmane.comp.lang.r.devel/9704 [4] R version 2.4.0 alpha (2006-09-19 r39410) [5] R version 2.5.0 Under development (unstable) (2006-09-19 r39410) -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
On Tue, 2006-09-19 at 17:29 +0100, 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.<snip /> Before I get asked for it, here's the sessionInfo() - apologies for not supplying it originally.> version_ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status alpha major 2 minor 4.0 year 2006 month 09 day 19 svn rev 39410 language R version.string R version 2.4.0 alpha (2006-09-19 r39410)> sessionInfo()R version 2.4.0 alpha (2006-09-19 r39410) i686-pc-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" [7] "base" -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
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.> 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?> 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. -- Brian D. Ripley, ripley at stats.ox.ac.uk 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, UK Fax: +44 1865 272595
Gavin, the advice given here: http://tolstoy.newcastle.edu.au/R/help/02b/4378.html works on FreeBSD 6.1. Try:> pdf("~/tmp/test_per_mille.pdf", paper = "a4", family = "URWBookman",+ encoding="WinAnsi.enc")> plot(1:10, ylab="\211") > dev.off()Cheers Andrew On Tue, Sep 19, 2006 at 05:29:40PM +0100, 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). > > 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.: > > 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. > > I've tried this in R 2.4.0 alpha [4] and R 2.5.0 to be [4] as my > self-compiled R 2.3.1-patched dies when plotting Unicode characters > (fixed in 2.4.0 alpha and above [3]) > > Can anyone point me in the right direction to get this working? > > TIA, > > G > > [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48709.html > [2] like a "%" but with 2 circles at the bottom not one, see > http://en.wikipedia.org/wiki/Permille > [3] see thread at http://article.gmane.org/gmane.comp.lang.r.devel/9704 > [4] R version 2.4.0 alpha (2006-09-19 r39410) > [5] R version 2.5.0 Under development (unstable) (2006-09-19 r39410) > -- > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% > 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 > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code.-- Andrew Robinson Department of Mathematics and Statistics Tel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: a.robinson at ms.unimelb.edu.au http://www.ms.unimelb.edu.au
Hi 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).I get the same thing (and using xfd I see the per mille character in the font I'm using). I'm afraid I'm not sure why this is happening; I can get a number of other "unusual" characters to work (e.g., \u20ac), but there appear to be some characters that do not draw correctly. I used the following code to explore the default Helvetica font I've got and I can't see a rational pattern in the misbehaviour. x11(width=5, height=5) grid.prompt(TRUE) digits <- c(0:9, letters[1:6]) for (i in c("00", "01", "02", "03", "1e", "20", "21", "22")) { grid.newpage() for (j in 1:16) { for (k in 1:16) { pushViewport(viewport(x=j/16, y=1-k/16, width=1/16, height=1/16, just=c("right", "bottom"))) eval(parse(text=paste('grid.text("\\u', i, digits[k], digits[j], '")', sep=""))) popViewport() } } }> 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.: > > 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.This is an encoding problem I think. For producing PDF output, the character string gets converted to a single-byte encoding. If your default locale is ISOLatin1 like mine then you won't see the per mille because that character (called perthousand in the Adobe afm's) is not in the ISOLatin1 encoding. If you explicitly use an encoding that does include perthousand (like WinAnsi) then the conversion to single-byte encoding works. For example, this works (for me at least) ... pdf("WinAnsi_per_mille.pdf", encoding="WinAnsi") plot(1:10, ylab = "\u2030") dev.off() Paul> I've tried this in R 2.4.0 alpha [4] and R 2.5.0 to be [4] as my > self-compiled R 2.3.1-patched dies when plotting Unicode characters > (fixed in 2.4.0 alpha and above [3]) > > Can anyone point me in the right direction to get this working? > > TIA, > > G > > [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48709.html > [2] like a "%" but with 2 circles at the bottom not one, see > http://en.wikipedia.org/wiki/Permille > [3] see thread at http://article.gmane.org/gmane.comp.lang.r.devel/9704 > [4] R version 2.4.0 alpha (2006-09-19 r39410) > [5] R version 2.5.0 Under development (unstable) (2006-09-19 r39410)-- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/