[R] [rgl] Dynamically change the color of 3d objects

Duncan Murdoch murdoch.duncan at gmail.com
Sun Jun 19 13:15:20 CEST 2011


On 11-06-18 3:47 PM, Fernando (Est - UnB) wrote:
> Hi,
>
> I'm new here.
>
> This question concerns the package rgl.
>
> Is it possible to change the colour of a set of points drawn with
> plot3d /without/ removing them from the scene?

No, you can't modify objects other than by removing and recreating them.

>
> The idea is to create a presentation of a clustering algorithm, step
> by step, representing the currently assigned cluster by a colour.
> Removing all the points with "rgl.pop" and replotting them at each
> step works, but is kinda slow...

If you do it this way:

# plot the points, and save the id in pointsID

par3d(skipRedraw=TRUE)
rgl.pop(pointsID)
pointsID <- points3d(  ...  ) # plot the points again
par3d(skipRedraw=FALSE)

it will go faster, and appear to the viewer as though the colour just 
changed, with no removal of points.

Duncan Murdoch



More information about the R-help mailing list