[R] scatter3d: problem with spheres-color

John Fox jfox at mcmaster.ca
Fri Apr 13 03:17:44 CEST 2012


Dear Duncan,

I'm now home and have access to Windows and Mac OS X systems, but not Ubuntu. scatter3d(prestige ~ income + education | type, data=Prestige) works perfectly fine on both the Windows and Mac systems, as do the rgl.spheres() and spheres3d() commands that you suggested trying.

I think that you know that the original version of scatter3d() antedated the *3d functions in rgl, and much of the code still uses the rgl.* functions. This, though, is the first problem that's surfaced, at least to my knowledge, and it oddly seems confined to Linux. 

When I have a chance I'll try using spheres3d() in scatter3d() and will see whether the problem goes away under Linux, but I won't be able to check that until early next week. Maybe René can try out the rgl.spheres() and spheres3d() commands in the interim.

Thank you for looking at the issue.

John

On Thu, 12 Apr 2012 17:37:09 -0400
 Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 12/04/2012 2:27 PM, John Fox wrote:
> > Dear René,
> >
> > I've confirmed that the spheres aren't coloured correctly on my Ubuntu system (the first colour is used for all of the spheres), and I know that this works right on Windows, as you mentioned. I'm curious to try it on my Mac, but don't have that handy at the moment.
> >
> > I also looked at the code for scatter3d.default(), and that is pretty straightforward; scatterplot3d.default() draws the spheres with the command
> >
> >      rgl.spheres(x, y, z, color = surface.col[as.numeric(groups)],
> >                  radius = size)
> >
> > I'm copying this response to Duncan Murdoch (the coauthor and maintainer of the rgl package) in case he has any insight into the problem.
> >
> > Thank you for drawing this issue to my attention.
> 
> 
> Calling rgl.spheres looks dangerous to me:  the rgl.* functions make permanent changes to material properties.  Generally it's safer to call spheres3d, as all of the *3d versions of functions make local changes.
> 
> But there should be no differences in that between Ubuntu and Windows.  Can you put together a simple example that does give differences?  For example, on Windows this gives 5 different colours:
> 
> rgl.spheres(1:5, 1:5, 1:5, col=1:5, radius=(1:5)/10)
> 
> My preferred version would be
> 
> spheres3d(1:5, 1:5, 1:5, col=1:5, radius=(1:5)/10)
> 
> Do they behave the same?
> 
> Duncan Murdoch



More information about the R-help mailing list