R plots some unicode characters but not others R plots some unicode characters but not others r r

R plots some unicode characters but not others


Maybe your text editor is using latin1, therfore you would send latin1 characters to your console.

Look at the encoding

Encoding('ʘ')

and / or try

plot(1, xlab=iconv('ʘ', from='latin1', to="UTF-8"))

but be carefull the encoding could change while coping.If you use Notepad++ you can convert in the text editor between the different encodings.


Note: I suppose with a new system you should first do:

capabilities() #And see what the result for cairo is.

A couple of ideas although one of them requires knowing what fonts you are using so the output of l10n_info()$MBCS and names(X11Fonts()) might be needed.

Option 1) The Hershey fonts have all the astrological signs as special escape characters. Page 4 of the output of :

 demo(Hershey)   # has \\SO as the escape sequence for the "solar" symbol.

So looking at the code for the draw.vf.cell function we see that it's using the text function to plot those characters and therefore using it to label an axis will require adding xpd=TRUE to the arguments:

plot(1, xlab="") ; text(1, .45, "\\SO" , vfont=c("serif", "plain"), xpd=TRUE )

enter image description here

Option 2) find the solar symbol in the font of your choice. You might try setting the font to something other than "Helvetica". See ?X11 that has a section on Cairo fonts. The points function's help page has a function called TestChars that lets you print character glyphs in various fonts to your output device. In this case your output device might be either cairopdf or x11. On my device (the Mac fork of UNIX) the Arial font has this output:

   png(type="cairo-png");plot(1, xlab="\u0298");dev.off()

My observation over the years of similar questions leads me to believe that Cairo graphics are more reliably cross-platform. But since R can be compiled without cairo support, it's not a sure thing.

enter image description here