Search code examples
rrgl

using plot3D to color rows in specific color


I have a table A with 4000 rows and 3 columns, where x y z look like

x  y  z
1  3  6
2  4  6
3  5  6
5  2  5

I want to draw it with plot3D

library(plot3D)
library(rgl)
plot3d(A)

However, I want to make row 1-1000 color in red, 2000-3000 color in black,etc. How to get it please?

Update: thanks for nongkrong's answer. I have the following code works:

plot3d(A,col=rep(1:4,each=1000))

Solution

  • something along the lines of

    with(yourData, scatter3D(x, y, z, col=rep(1:4, each=1000)))