Sys.setlocale() and text()
On Wed, 12 Dec 2007, Ed Merkle wrote:
Thanks very much for the response. I think I left out an important detail, however. I want my lowercase sigma to be displayed in a specific font from the Rdevga file (my project involves fonts). So far as I know, quote() does not allow me to select a font. Thus, I am specifically interested in the text() command and reasons why my example code performs differently in R 2.3.0 vs 2.6.1.
I think the only thing which needs explaining is why it worked in 2.3.1: you can't usually switch 8-bit locales in an application on Windows and expect to get the right font. Most likely it was fortuitous that it worked: it was only intended to work in a multibyte locale (see the entry in CHANGES for 2.3.0), and that principally to aid testing of non-Western locales by the developers. But if you are really interested in differences then you will need to study the changes in the source code for yourself: the price you paid does not include that level of support. One of the holdups has been that we tried still to support Windows 9X/ME. That will be dropped as from R 2.7.0 and so we can use Unicode to access the glyphs via text(). Your example works for me in R-devel, so please try that in a day or two (I think it needs a recent change). Note though that switching locales within a session is fragile: it invalidates all existing 8-bit data, and so for example repainting the graphics window or the console can change the glyphs displayed. (In R-devel, try changing back to US and resize the graphics window.)
Thanks, Ed Gabor Grothendieck wrote:
Try this: plot(1:10, main = quote(sigma ^ 2)) On Dec 11, 2007 10:09 PM, Ed Merkle <edgar.merkle at wichita.edu> wrote:
Dear HelpeRs,
I have a question about the Sys.setlocale() command and plotting. I am
running Windows XP, with R 2.6.1. My default locale is English_United
States.1252.
I am trying to add a lowercase sigma to a plot using the following code:
Sys.setlocale("LC_CTYPE","greek")
plot(1:10,1:10)
text(4,3,"\xF3")
For R 2.6.1, this code gives me the glyph from my default (1252) instead
of from the 1253 codes. For an older version of R (2.3.0) on the same
computer, this code gives me the lowercase sigma that I wanted. I have
been unable to pinpoint what has changed. Thanks for the help, and I
apologize if I am missing something obvious.
--
Ed Merkle, PhD
Assistant Professor
Dept. of Psychology
Wichita State University
Wichita, KS 67260
______________________________________________ R-help at r-project.org 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.
______________________________________________ R-help at r-project.org 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.
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