Question: R RGL plot3d different symbols
0
gravatar for dp0b
3 months ago by
dp0b30
dp0b30 wrote:

Hi,

I was wondering is it possible to have different symbols used in R RGL package using plot3d? I have assigned different colours but have more variables I need to add so a difference in shape would help.

Thanks in advance

library(rgl)
cols=c("brown","red","blue","coral1", "green", "black", "cyan", "yellow","deeppink", "orange", "purple","deeppink4","chartreuse4")
col = cols[as.numeric(pca$breed)]
legend3d("topright", legend = uniqueID, pch=19,col=cols[as.numeric(uniqueID)], cex=0.9, inset=c(0.03))
plot3d(pca[1:3],col=col,size=6)
pca R rgl • 248 views
ADD COMMENTlink modified 10 weeks ago by Alex Reynolds27k • written 3 months ago by dp0b30

Did you try using the pch argument? Instead of assigning one value (19), try to map your groupings?

ADD REPLYlink modified 10 weeks ago • written 10 weeks ago by zx87546.8k
2
gravatar for Alex Reynolds
10 weeks ago by
Alex Reynolds27k
Seattle, WA USA
Alex Reynolds27k wrote:

Perhaps this example may help:

point.styles <- sample(10:19, 10, replace=T)
x1 <- sort(rnorm(10))
y1 <- rnorm(10)
z1 <- rnorm(10) + atan2(x1, y1)
x2 <- sort(rnorm(10))
y2 <- rnorm(10)
z2 <- rnorm(10) + atan2(x2, y2)
x3 <- sort(rnorm(10))
y3 <- rnorm(10)
z3 <- rnorm(10) + atan2(x3, y3)
library(rgl)
open3d()
pch3d(x1, y1, z1, color="red", bg="red", pch=point.styles)
pch3d(x2, y2, z2, color="blue", bg="blue", pch=point.styles)
pch3d(x3, y3, z3, color="green", bg="green", pch=point.styles)
axes3d()

On my end, unfortunately, it looks like separate calls to pch3d() were required for each subset of points, in order to render that subset of points with its own color. Perhaps try to pass a vector of colors, but if it doesn't work, the approach above seemed to work for me.

ADD COMMENTlink written 10 weeks ago by Alex Reynolds27k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2381 users visited in the last hour