Axis labels with non-English (but Latin) characters

1,052 views
Skip to first unread message

Jan

unread,
Sep 28, 2009, 9:29:22 AM9/28/09
to ggplot2
Hi everybody
I belong to one of those unfortunate nationalities that have come up
with their own extensions to the A-Z alphabet.
All Nordic countries in addition have 'Æ/Ä', 'Ø/Ö' or 'Å'. However,
these never show up properly in plots made with ggplot() or qplot().
This forces me to either use English notation or 'fake it' by
replacing with 'ae', 'oe' or 'aa'.
Is there any way I can tweak them into displaying properly in my
plots ?
My system is Windows XP, R version 2.9.2 and Eclipse with the StatET
plugin

hadley wickham

unread,
Sep 28, 2009, 11:04:16 AM9/28/09
to Jan, ggplot2
Hi Jan,

Could you please provide a reproducible example?

Hadley
--
http://had.co.nz/

baptiste auguie

unread,
Sep 28, 2009, 1:25:32 PM9/28/09
to ggplot2, Jan
Works for me,

qplot(1,1, main=" 'Æ/Ä', 'Ø/Ö' or 'Å'")

(screenshot attached)

Do you have your locale set to UTF8?

HTH,

baptiste

sessionInfo()
R version 2.9.2 (2009-08-24)
i386-apple-darwin8.11.1

locale:
en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
Picture 3.png

Andreas Christoffersen

unread,
Sep 28, 2009, 4:59:41 PM9/28/09
to baptiste auguie, ggplot2, Jan
Hi all,

This is really a bit off topic as it is not a ggplot thing: I am from Denmark and have no problem plotting danish æøå on axis labels with ggplot2. But when using the pdf device - the title will not show æøå.

e.g.
pdf("filename.pdf",paper="a4r",width=11, height=8,
    title="something with æåø",
    encoding="ISOLatin1")

Shows up all wrong. Also if encoding is set to utf-8

help is appreciated. (using latest R on crunchbang linux 9.04 with danish locale settings, but english as default language)

Jan

unread,
Sep 29, 2009, 3:48:37 AM9/29/09
to ggplot2
Hi again.
Thanks for all the helpful answers, I alternate between a Mac OS X and
a Windows installation, and this has caused me no problems until now.
Thanks to you, I realise that it all has to do with locale settings,
Windows uses cp1252 as default, whereas the Mac uses UTF-8.
However, my problems do not seem to be related to ggplot2 (yay!)
It definitely seems to be a problem with the Eclipse/StatET
combination, as I can run my files fine in the R console. The graphs
print with æøå, no problem. The problem is the R console that is run
from within Eclipse. Even though I have set the encoding to CP1252 in
that particular console as well as in the text editor, somewhere along
the line (it at least *looks* normal when the code is parsed in the
console, but the graph always shows garbled characters)
Thanks for the help, but it seems I must look elsewhere for a
solution....

Jan

On Sep 28, 10:59 pm, Andreas Christoffersen
<achristoffer...@gmail.com> wrote:
> Hi all,
>
> This is really a bit off topic as it is not a ggplot thing: I am from
> Denmark and have no problem plotting danish æøå on axis labels with ggplot2.
> But when using the pdf device - the title will not show æøå.
>
> e.g.
> pdf("filename.pdf",paper="a4r",width=11, height=8,
>     title="something with æåø",
>     encoding="ISOLatin1")
>
> Shows up all wrong. Also if encoding is set to utf-8
>
> help is appreciated. (using latest R on crunchbang linux 9.04 with danish
> locale settings, but english as default language)
>
> On Mon, Sep 28, 2009 at 7:25 PM, baptiste auguie <bapt4...@googlemail.com>wrote:
>
>
>
> > Works for me,
>
> >  qplot(1,1, main=" 'Æ/Ä', 'Ø/Ö' or 'Å'")
>
> > (screenshot attached)
>
> > Do you have your locale set to UTF8?
>
> > HTH,
>
> > baptiste
>
> > sessionInfo()
> > R version 2.9.2 (2009-08-24)
> > i386-apple-darwin8.11.1
>
> > locale:
> > en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
>
> > On Mon, Sep 28, 2009 at 5:04 PM, hadley wickham <h.wick...@gmail.com>
> > wrote:
>
> > > Hi Jan,
>
> > > Could you please provide a reproducible example?
>
> > > Hadley
>

baptiste auguie

unread,
Sep 29, 2009, 4:21:02 AM9/29/09
to Jan, ggplot2
Should everything else fail, you might have better luck with the new
tikzDevice package that gives you the full power of LaTeX typesetting
for the various text labels in your plot. (I don't know how you'd
typeset these particular characters in TeX though).


Best,

baptiste
Reply all
Reply to author
Forward
0 new messages