Using pch with the RGL library

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using pch with the RGL library

Iuri Gavronski
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)

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Using pch with the RGL library

Duncan Murdoch
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)
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.