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


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))
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
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)
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 written 10 weeks ago by Alex Reynolds27k
Please log in to add an answer.


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