how do i plot a german "umlaut"

565 views
Skip to first unread message

Herbert Jägle

unread,
Feb 3, 2013, 4:46:47 PM2/3/13
to ggp...@googlegroups.com
Hi,

I want to plot a german Umlaut like äöü i in the title using

ggtitle('Überschrift')
or
ggtitle('\x86berschrift')

but get the following error:
Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  invalid multibyte string at '<86>berschrift'
Calls: source ... <Anonymous> -> heightDetails -> heightDetails.text -> grid.Call

Any help appreciated!

My sessionInfo is listed below.

Thanks,
Herbert

---sessionInfo()---
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C/en_US.UTF-8/C/C/de_DE/C

attached base packages:
[1] datasets  splines   utils     graphics  grDevices grid      stats     methods   base    

other attached packages:
 [1] extrafont_0.13    pROC_1.5.4        irr_0.84          lpSolve_5.6.6     psych_1.2.12    
 [6] psyphy_0.1-7      signal_0.7-2      ROCR_1.0-4        gplots_2.11.0     KernSmooth_2.23-8
[11] caTools_1.14      gdata_2.12.0      gtools_2.7.0      Hmisc_3.10-1      survival_2.37-2 
[16] random_0.2.1      stringr_0.6.2     plyr_1.8          lattice_0.20-13   MASS_7.3-23     
[21] gtable_0.1.2      gridExtra_0.9.1   ggplot2_0.9.3     reshape2_1.2.2  

loaded via a namespace (and not attached):
 [1] RColorBrewer_1.0-5 Rttf2pt1_1.1       bitops_1.0-4.2     cluster_1.14.3   
 [5] colorspace_1.2-1   dichromat_2.0-0    digest_0.6.2       labeling_0.1     
 [9] munsell_0.4        proto_0.3-10       scales_0.2.3     



Ryan Hope

unread,
Feb 5, 2013, 12:04:04 AM2/5/13
to ggp...@googlegroups.com
I am also interested in how to use unicode characters in things like axis labels.

Herbert Jägle

unread,
Feb 5, 2013, 2:40:17 PM2/5/13
to ggp...@googlegroups.com
In the meanwhile i received some suggestions to test and found the following code to work in R64 started from the sh:

ggtitle('Überschrift')
ggtitle('\xC3\x9Cberschrift')

The code "ggtitle('\x86berschrift')" does not print a title, but it also does not generate an error message.

So i tried the same within "R console" and found that if i input the text at the cursor it will print correctly as well, but it does not work within a script file.

And i just found a comment "[R-SIG-MAC] Text encoding and R" explaining that sourcing is only possible if R is told the encoding of the file like: source("file.R", enc="MacRoman")
However, this comment is from 2007, so there may be a chance this has changed.

Does anyone know if it is possible to tell the "R console" which default encoding should be used for sourcing?

If this still is not possible, how to encode these characters otherwise in scripts?

Any suggestions are very appreciated.
Herbert
Reply all
Reply to author
Forward
0 new messages