[R] rgl 'how-to's

Duncan Murdoch murdoch.duncan at gmail.com
Thu Sep 8 11:57:55 CEST 2011


On 11-09-07 6:07 PM, Dale Coons wrote:
> Doing a visual graphic and trying to make it "pretty"
>
> Here's simple chart to play with:
>
> library(rgl)
> dotframe<-data.frame(x=c(0,7,0,0,-7,0),y=c(0,0,7,0,0,-7),z=c(7,0,0,-7,0,0))
> dotframe plot3d(dotframe$x,dotframe$y,dotframe$z, radius=3,
> type='s',col=c('red','green','blue','purple','orange','gray'),
> axes=FALSE, box=FALSE, xlab='',ylab='',zlab='')
>
> text3d(x=7,y=0,z=0, text="hello, world",adj = 0.5, color="blue") #adds a
> label at one of the points
>
> My questions:
>
> 1) is there a way to label the points (spheres in this case) so that the
> label 'stays on top'?  other than text3d(), which adds labels, but they
> are hidden when the graph is rotated?

Yes, but it's not trivial.  You need to write your own mouse handler, 
that erases the old labels, rotates the data, and replots the labels 
afterwards.  This would be quite feasible with a small number of labels, 
but maybe not if you have too many:  the delays for replotting would be 
noticeable.

> 2) can a bitmap, say, of a company or university be inserted into the
> title area?

I think so, by plotting a "sprite" with the bitmap as a "texture". See 
?sprites3d.

> 3) can a bitmap be used as the marker for a point?

That also sounds like a sprite.

Duncan Murdoch

>
> Thanks in advance for help-I learn a lot from others questions and
> appreciate direction (even if it's RTFM!)
>
> Dale
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list