This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R RGL plot3d different symbols

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)
r pca rgl

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

1 answer

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.

Log in to answer this question.