r - R中通过汽车包绘制三维散点图

标签 r graph

我正在尝试通过 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()

enter image description here

问题

  1. 如何从图中删除数据圆圈?
  2. 如何将绘图保存为 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")

enter image description here

关于r - R中通过汽车包绘制三维散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15448793/

相关文章:

r - 独特元素的值(value)

r - 当某些部分为空时如何转换日期或日期时间字段; na.omit 失败

r - 如何在同一页面中打印多个绘图(ggplot)

c++ - 使用迭代深度优先搜索算法的未加权图的最短路径

algorithm - 给定图中的旧最小生成树,是否存在用于将新节点添加到最小生成树的 O(|V|) 算法?

excel - MS Excel等数据分析工具

r - 在 data.table 列上使用 %in% 运算符

graph - Tinkerpop - 使用 Redis 进行键值属性索引更好还是使用 KeyIndexableGraph

c++ - CERN 根目录 : Is is possible to plot pairs of x-y data points?

r - 根据@data 插槽中的字段合并空间多边形数据框中的多边形