[R] Using pch with the RGL library

Iuri Gavronski iuri at ufrgs.br
Mon Apr 5 20:27:54 CEST 2010


Hi,

I am trying to compare two 3D plots. For that, I am trying to use the
"pch" parameter in the "points3d" function, but it is not working. Is
it implemented? Any suggestion?

Here goes a reproducible code. I wanted the second plot having
different symbols for the points.

x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
           matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2),
           matrix(rnorm(100, mean = 2, sd = 0.3), ncol = 2))
colnames(x) <- c("x", "y", "z")
k1<-kmeans(x,3)
k2<-kmeans(x,3,algorithm = "Lloyd")
library(rgl)
plot3d(x,col=k1$cluster)
points3d(x+.02,pch=8,col=k2$cluster)



More information about the R-help mailing list