[R] Is it possible to "right align" text in R graphics?
David Winsemius
dwinsemius at comcast.net
Wed Jan 4 08:49:43 CET 2012
On Jan 3, 2012, at 5:32 PM, Tal Galili wrote:
> And I forgot to include the link to the image, here it is:
>
> http://dl.dropbox.com/u/5371432/right-to-left-text%20example%202.png
I'm assuming this should be compared to the second of your three
examples.
The aleph ( ש ) is on the left end of both titles.
I did notice in the process of deleting some inserted Hebrew letters
at the command line of the MacGUI that at one point the r-prompt (">")
got swapped to the right end of the glyph sequence. It also appears
that the Mac supports different inserion modes. Further testing shows
that back-quoted Hebrew text will cause that right-positioning to occur:
(But when I paste the formula into my mail the reversal diappears;)
> יים` ~ `שלוש`
I also searched on "reverse hebrew" in RSiteSearch, finding your
questions from last year. The test you offered ran without difficulty
on a Mac (since the file at you website is still up).
There is mention of a BiDi (bidirectional) class in package Unicode.
And there is a help page for:
http://finzi.psych.upenn.edu/R/library/RGtk2/html/pango-Bidirectional-Text.html
> sessionInfo()
R version 2.14.0 Patched (2011-11-13 r57650)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
--
David.
>
> On Wed, Jan 4, 2012 at 12:30 AM, Tal Galili <tal.galili at gmail.com>
> wrote:
> Thanks to an e-mail from David, I realized that non-Hebrew speakers
> will not be able to know how a proper right-to-left output should
> look like (sorry for not thinking about it myself...)
>
> Here is some example code of how the output should look like vs how
> it currently looks.
> This is shown only for the main parameter, but the same issue will
> come up when using ?title or ?text
>
> Two points to mention again:
> 1) This is not a huge problem for me personally, but I believe that
> in the long term, if such an issue can be fixed, it would have been
> nice. It will allow all of the right-to-left languages to use R for
> plotting in their own language (That included, for example, all of
> the Arabic world... http://en.wikipedia.org/wiki/Right-to-left ).
> 2) I fear that this type of issue needs to be handled by someone
> familiar with the guts of the R graphics code. I am not even sure
> if I should post this here or on the R-devel mailing list. Your
> advise will be very welcome.
>
>
> Here is the example code:
>
> par(mfrow = c(1,2))
> plot(1:10, main = "שלום (טקסט)", sub = "The order of text is
> not right to left")
> plot(1:10, main = "(שלום (טקסט", sub = "This is how the
> output should have looked like")
>
> # A more complex example:
> plot(1:10, main = "שלום (טקסט) מידע על Subject 1", sub
> = "The order of text is not right to left")
> plot(1:10, main = " Subject 1 שלום (טקסט) מידע על", sub
> = "This is how the output should have looked like")
>
> # An even more complex example:
> par(mfrow = c(1,1))
> plot(1:10, main = "שלום (טקסט) מידע על Subject 1 וגם
> קצת מידע על subject 2", sub = "The order of text is not
> right to left")
> # I am not sure how to fix this actually...
>
>
> Happy new year,
> Tal
>
>
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: Tal.Galili at gmail.com | 972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il
> (Hebrew) | www.r-statistics.com (English)
> ----------------------------------------------------------------------------------------------
>
>
>
>
> On Thu, Dec 29, 2011 at 6:52 PM, Tal Galili <tal.galili at gmail.com>
> wrote:
> Hello all,
>
> The following line of code includes a right-to-left language text,
> yet the R graphics engine displays it from left to right. One
> problem this causes is when there are parenthesis in the test, here
> is a basic example?
>
> plot(1:10, main = "שלום (טקסט)")
>
> Is there a way to make sure the text is displayed from right to left?
>
> Many thanks for any suggestions,
> Tal
>
>
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: Tal.Galili at gmail.com | 972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il
> (Hebrew) | www.r-statistics.com (English)
> ----------------------------------------------------------------------------------------------
>
>
>
>
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list