Question: R RGL plot3d different symbols
Entering edit mode
8 months ago
dp0b • 30


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

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))
ADD COMMENTlink 9 months ago dp0b • 30 • updated 8 months ago Alex Reynolds 28k
Entering edit mode

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

ADD REPLYlink 8 months ago
Entering edit mode
8 months ago
Alex Reynolds 28k
Seattle, WA USA

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

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 8 months ago Alex Reynolds 28k

Login before adding your answer.

Powered by the version 1.5