平面 R 着色问题中的 scatter3D

scatter3D in R Colouring Issue with Plane

我正在使用库 plot3D 中的 scatter3D 并绘制带有预测平面的散点图:

library(plot3D)   
scatter3D(x1,x2,y, bty = "g",
              pch = 20, cex = 2, ticktype = "detailed",
              surf = list(x = sort(unique(x1_new)), y = sort(unique(x2_new)), z = z.pred ,  
                          facets = NA
                          ))

我的 y 范围从 -1 到 1,但是 z.pred 中的一些预测低于 -1。因此,您会注意到低于 -1 的预测未着色,因为它们超出了色标。我该如何解决?

试试这个:

library(plot3D)   
scatter3D(x1,x2,y, bty = "g",
              pch = 20, cex = 2, ticktype = "detailed",
              surf = list(x = sort(unique(x1_new)), y = sort(unique(x2_new)), z = z.pred ,  
                          facets = NA
                          ),clim=c(min(y,z.pred),max(y,z.pred))