R RGL plot3d different symbols
1
1
Entering edit mode
6.0 years ago
dp0b ▴ 80

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 • 3.3k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
2
Entering edit mode
5.9 years ago

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 COMMENT

Login before adding your answer.

Traffic: 1808 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6