[R] scatter3d: problem with spheres-color

Duncan Murdoch murdoch.duncan at gmail.com
Fri Apr 13 13:14:38 CEST 2012


On 12-04-13 5:32 AM, René Mayer wrote:
> Dear John and Duncan,
>
> thanks for your ideas! Unfortunatly, calling spheres from rgl
> did not resolve the problem on my machine.
>
> Both - spheres3d() and rgl.spheres() -
> behave the same: black spheres, all aqual colored.
> The only difference beeing the looking angle and thebackround color.
> Seems to me that the 'col=1:5' argument is completly ignored.

Could you try this:  After using one of the commands that's not working 
(e.g. my spheres3d command from below), run the following:

rgl.ids()

This will give a dataframe of objects in the scene, something like

   id    type
1  6 spheres


(There will be more things listed if you have plotted other objects, and 
the id number could be different.)  Then run

rgl.attrib(6, "color")

(The 6 is the id associated with the spheres object.)

On my system after my spheres3d() call below, this gives

 > rgl.attrib(6, "color")
      r         g b a
[1,] 0 0.0000000 0 1
[2,] 1 0.0000000 0 1
[3,] 0 0.8039216 0 1
[4,] 0 0.0000000 1 1
[5,] 0 1.0000000 1 1

Can you tell me what you get? If you get the same thing as me, then 
you've got a rendering problem; if you only see black colors listed, 
then it's a problem at a higher level.

Duncan MUrdoch

>
> René
>
>
>
> Zitat von "Duncan Murdoch"<murdoch.duncan at gmail.com>:
>
>> 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