[R] Using pch with the RGL library

Duncan Murdoch murdoch at stats.uwo.ca
Mon Apr 5 21:21:17 CEST 2010


On 05/04/2010 2:27 PM, Iuri Gavronski wrote:
> 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?
>   

Try reading the help page for points3d.  There is no "pch" mentioned.  
You can plot different characters using text3d, but the list of symbols 
that plot shows with numerical pch values just don't exist in rgl.

Duncan Murdoch
> 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)
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list