R中使用rgl plot3d的三维散点图 - 每个数据点的大小不同?

Jac*_*ith 3 r scatter-plot rgl

我在用

plot3d(x,y,z, col=test$color, size=4) 
Run Code Online (Sandbox Code Playgroud)

绘制我的数据集R的3D散点图,但rglsize说法只需要一个尺寸.

是否可以为每个数据点设置不同的大小,可能是另一个库,还是有一个简单的解决方法?

谢谢你的想法!

Jos*_*ien 6

这是Etienne建议的同样的解决方法.关键的想法是设置图,然后使用单独的调用points3d()来绘制每个尺寸类中的点.

# Break data.frame into a list of data.frames, each to be plotted 
# with points of a different size
size <- as.numeric(cut(iris$Petal.Width, 7))
irisList <- split(iris, size)

# Setup the plot
with(iris, plot3d(Sepal.Length, Sepal.Width, Petal.Length, col=Species, size=0))

# Use a separate call to points3d() to plot points of each size
for(i in seq_along(irisList)) {
    with(irisList[[i]], points3d(Sepal.Length, Sepal.Width, 
                                 Petal.Length, col=Species, size=i))
}
Run Code Online (Sandbox Code Playgroud)

(FWIW,似乎没有办法plot3d()直接这样做.问题是plot3d()使用辅助函数material3d()来设置点大小,如下所示,material3d()只想获取一个数值.)

material3d(size = 1:7)
# Error in rgl.numeric(size) : size must be a single numeric value
Run Code Online (Sandbox Code Playgroud)