我正在尝试通过 car
包在 R
中制作三维散点图。 MWE 如下。
pdf(file = "Hyperellipsoid.pdf")
library(car)
scatter3d(
prestige ~ income + education
, xlab = ""
, ylab = ""
, zlab = ""
, surface=FALSE
, fill=FALSE
, grid=TRUE
, axis.scales=FALSE
, ellipsoid=TRUE
, axis.col= "white"
, square.col= "white"
, point.col = "white"
, data=Duncan
)
dev.off()
问题
- 如何从图中删除数据圆圈?
- 如何将绘图保存为 pdf 格式?
最佳答案
您实际上并不需要破解完整的散点图函数(您可以通过 car:::scatter3d.default
更轻松地看到它);你可以只使用car:::ellipsoid
。
library("car")
dmat <- subset(Duncan,select=c(income,education,prestige))
dfn <- 3
dfd <- nrow(Duncan) - 1
level <- 0.95
ell.radius <- sqrt(dfn * qf(level, dfn, dfd))
library("rgl")
open3d()
rgl.material(color="blue")
ellips <- car:::ellipsoid(center = colMeans(dmat),
shape = cov(dmat),
radius = ell.radius)
wire3d(ellips)
rgl.postscript("ell3d.pdf",fmt="pdf")
关于r - R中通过汽车包绘制三维散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15448793/