5

Do the rgl routines accept the use of "expression" for Greek letters and super/sub script for axis labelling?

Something like

xlab=(expression(paste("Lyman ",alpha,)))

works perfectly well in a normal plot call but just seems to display "(paste("Lyman ",alpha,)" as my axis label in plot3d and decorate3d. If not, how can I add these characters to my 3D scatterplots generated using plot3d?

Jota
  • 17,281
  • 7
  • 63
  • 93
  • Basically , no. The author and maintainer of pkg:rgl has said it would be nice but too difficult to build plotmath capability into that package. You need to tell us what font (which requires knowing which graphics device) you are using if you want accurate advice. – IRTFM May 01 '15 at 16:24
  • I thought I might be able to come up with a kludgy answer but have basically failed. Duncan Murdoch at times in the past has suggested using a "sprite" to which you have bitmapped the desired symbol. – IRTFM May 01 '15 at 16:48
  • OK. Shame, but thanks for clarifying that it is not possible. I'll just have to paste the labels on using a lesser package then. – Karen Aplin May 04 '15 at 08:26
  • This was what I hammered together for someone who wanted a floating rgl legend: http://stackoverflow.com/questions/19045208/adding-a-legend-to-scatter3d-plot/19057476#19057476. It's sometimes possible to build character values that print out greeks using UTF-8 or Unicode. This requires know what glyphs are in your RGL fonts. In my console font I get the lowercase greeks with: `intToUtf8(945:960) [1] "αβγδεζηθικλμνξοπ"` – IRTFM May 04 '15 at 08:44
  • 1
    The Unicode modern greeks: http://www.alanwood.net/demos/symbol.html#s0370 (The lowercase greeks also start at 945.) – IRTFM May 04 '15 at 08:53

1 Answers1

3

On my system (OSX 10.7.5, R 3.1.2) I get an alpha as xlab with:

require(rgl)
plot3d(1,1,1,xlab=intToUtf8(0x03B1L) )

And pasting to ordinary text also succeeds:

plot3d(1,1,1, xlab=paste("Lyman ", intToUtf8(0x03B1L) ) )
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • That works on my Mac (OS X 10.10.3, R3.1.2) as well, thanks. However on my Windows 7 machine (R3.0.1) the alpha character is just showing as an "a". I can see the lowercase greeks with `intToUtf8(945:960)` as you describe above but then they won't display in the 3d plot window under Windows. Is there a similar trick for super- and sub-script by the way? – Karen Aplin May 04 '15 at 14:25
  • As I wrote, you need to know what fonts are being used and that is device dependent. I suggest you execute rglFonts() and then use the facilities provided in the help page for `points` to display text in the available fonts. If you have found what I have researched useful you should at least upvote this answer even if it is incomplete and not "check-worthy". – IRTFM May 04 '15 at 16:19
  • You should be able to install the Amaya fonts (link on the `?rglFonts` page) into your `../library/rgl/fonts/` ( wherever your windows device has its library and if you don't know then use `.libPaths()` to find it) and then execute the code at the bottom of that help page. – IRTFM May 04 '15 at 16:59
  • Sorry @BondedDust, I can't upvote you as I am new to the forum, but many thanks for the help. – Karen Aplin May 06 '15 at 15:53
  • Well, you've done all you could. I've upvoted your question and at 15 rep you will be able to upvote any useful questions you encounter in the future. (I was surprised that raw newbies are not given upvoterability.) – IRTFM May 06 '15 at 17:37