Majid Einian
2012-Jan-15 08:26 UTC
[R] Correct Localized Numbers on Plots, related to glibc!
Dear R Helpers, I want to localize my plots, i.e. the numbers by x & y axis be Persian, using Persian numerals and Persian decimal separator. I change the locale to fa_IR.utf8, but nothing on plots change. I can change the numerals shaping to Persian ones (???? instead of 1234) using some non-standard fonts but the decimal point is a problem. I asked about that in Persian-Computing mailing list and I got the answer that follows. I don't know how should I use this "l" flag mentioned in the answer in R plots (I'm using simple R plots, no special library). Has anybody had similar problem in any language (maybe Arabic, other languages I'm not sure use different numeral characters). Also I don't have e.g. French locale on my system to see if the decimal separator changes accordingly to locale for them. Thanks in advance. ----------------------------------------------------------------------------- Roozbeh Pournader <roozbeh at gmail.com> Tue, Dec 6, 2011 at 3:47 AM To: Majid Einian <einian85 at gmail.com> Cc: persian-computing at googlegroups.com The glibc model for generating numbers is kind of complex. For using native digits, one is supposed to use the "I" flag. For example, in order to get ????, you should do printf("%I.1f", 12.3). This is to make sure applications have a way to output both ASCII numbers, and native numbers. Roozbeh -- http://persian-computing.org/ http://groups.google.com/group/persian-computing/ ---------------------------------------------------------------------------------------------- On Tue, Nov 29, 2011 at 12:04 AM, Majid Einian <einian85 at gmail.com> wrote: I have found that decimal seperator in fa_IR.utf8 is . (dot), I thought it should be U+066B , any comments or ideas why it is not so? (I am trying to use Persian numbers in my plots in GNU R, if it might help.) decimal_point thousands_sep grouping int_curr_symbol currency_symbol "." "" "" "IRR" "????" mon_decimal_point mon_thousands_sep mon_grouping positive_sign negative_sign "??'" "?" "\003" "" "-" int_frac_digits frac_digits p_cs_precedes p_sep_by_space n_cs_precedes "0" "0" "0" "1" "0" n_sep_by_space p_sign_posn n_sign_posn "1" "1" "1" Regards, Majid Einian, PhD Candidate in "Economics", Graduate School of Management and Economics, Sharif University of Technology, Tehran, IRAN
Prof Brian Ripley
2012-Jan-15 11:07 UTC
[R] Correct Localized Numbers on Plots, related to glibc!
You need to read ?Sys.setlocale (surely part of the homework the R posting guide asked of you). It is vital that you give the 'at a minimum' information requested in the posting guide when asking such questions, and we also absolutely need to know what graphics device you are trying to use. On 15/01/2012 08:26, Majid Einian wrote:> Dear R Helpers, > > I want to localize my plots, i.e. the numbers by x& y axis be > Persian, using Persian numerals and Persian decimal separator. I > change the locale to fa_IR.utf8, but nothing on plots change. I canHow, precisely? Please show us exactly what you did, with a reproducible example.> change the numerals shaping to Persian ones (???? instead of 1234) > using some non-standard fonts but the decimal point is a problem. I > asked about that in Persian-Computing mailing list and I got the > answer that follows. I don't know how should I use this "l" flag > mentioned in the answer in R plots (I'm using simple R plots, no > special library). > > Has anybody had similar problem in any language (maybe Arabic, other > languages I'm not sure use different numeral characters). > Also I don't have e.g. French locale on my system to see if the > decimal separator changes accordingly to locale for them.It will if they followed the documentation.> Thanks in advance. > > ----------------------------------------------------------------------------- > Roozbeh Pournader<roozbeh at gmail.com> Tue, Dec 6, 2011 at 3:47 AM > To: Majid Einian<einian85 at gmail.com> > Cc: persian-computing at googlegroups.com > > The glibc model for generating numbers is kind of complex. For using > native digits, one is supposed to use the "I" flag. For example, in > order to get ????, you should do printf("%I.1f", 12.3). > > This is to make sure applications have a way to output both ASCII > numbers, and native numbers. > > Roozbeh > >-- 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