我想生成一个三维散点图,其中包含各组点的体积。类似于this,但在R。
这些可能是粗糙的球体或更复杂的东西,如上面链接的图像,老实说,我只是试图说明演示文稿的超体积重叠。似乎我可以为每组点建立核密度估计并绘制出来,但我无法弄清楚如何这样做。
我用作基础的散点图与此代码生成的散点图非常相似:
# Code from http://www.sthda.com/english/wiki/impressive-package-for-3d-and-4d-graph-r-software-and-data-visualization#change-the-color-by-groups
library(plot3D)
# Set up data
data(iris)
x <- sep.l <- iris$Sepal.Length
y <- pet.l <- iris$Petal.Length
z <- sep.w <- iris$Sepal.Width
# Make 3d scatterplot with colors by category
scatter3D(x, y, z, bty = "g", pch = 18,
col.var = as.integer(iris$Species),
col = c("#1B9E77", "#D95F02", "#7570B3"),
pch = 18, ticktype = "detailed",
colkey = list(at = c(2, 3, 4), side = 1,
addlines = TRUE, length = 0.5, width = 0.5,
labels = c("setosa", "versicolor", "virginica")) )
奖励:如果您可以告诉我如何编辑 hypervolume()包,以便绘制一个超级卷对象正常工作,那么您将会有我不朽的感激之情。有关问题的详细说明,请参阅here。