I'd like to do a 3D plot with scatter3d but don't know how to colour the dots based on the values of a fourth variable (here VAR4). Could someone kindly help me? It would be great if by adding these colours, I still keep the fading effect that is in the default version (the points the further in the 3D plot appear with a lighter colour). Thank you!
df <- data.frame(VAR4=c(10,52,78,34,13,54),
A=c(12, 8, 10, 7, 13, 15),
B=c(4,3,2,1,7,5),
C=c(1,3,2,1,3,1))
library(rgl)
library(car)
scatter3d(A ~B + C,color=VAR4, data=df, surface=F)