Search code examples
rcolorspointscatter3d

How to change point color only in scatter 3d plot using R?


I tried change point color to black in scatter3d plot using R, but failed. It is difficult to view data because the color of the point and the surface color overlap.

Could i get some ideas?

# scatter plot with regression plane
scatter3D(x, y, z, pch = 16, cex = 1,  alpha.col = 0.8, color="black", col = ramp.col(c("dark green", "khaki", "dark red")), bty="b2", 
          theta = 595, phi = 35, ticktype = "detailed", d=200,
          xlab = "", ylab = "", zlab = "",  
          surf = list(x = x.pred, y = y.pred, z = z.pred,  
                      facets=T, border="black"), main = "Room A")

enter image description here

Thank you!


Solution

  • You can follow your command with points3D and include add=TRUE.

    # scatter plot with regression plane
    scatter3D(x, y, z,  
              col = ramp.col(c("dark green", "khaki", "dark red")), bty="b2", 
              theta = 595, phi = 35, ticktype = "detailed", d=200,
              xlab = "", ylab = "", zlab = "",  
              surf = list(x = x.pred, y = y.pred, z = z.pred,  
                          facets=T, border="black"), main = "Room A")
    
    points3D(x, y, z, pch = 16, color="black", alpha = 0.8, add=TRUE)