3

我在网络和 StackOverflow 中搜索了高低,但我找不到如何调整scatter3d()函数中的轴。

我的示例代码是

library(mvtnorm)
library(rgl)
library(car)

# multivariate norm data, split into two groups
set.seed(41367)
sigma <- matrix(c(9,2,0,2,4,1,0,1,1), ncol=3)
pcaData <- data.frame(rmvnorm(n=100, mean=c(9,4,0), sigma=sigma), gl(2,50))

names(pcaData)<-c("PC1", "PC2", "PC3", "ID")

# Obtain overall min and max across all numerical data
minScale <- min(pcaData[,1:3]) # = -1.883 from 3rd column
maxScale <- max(pcaData[,1:3]) # = 16.309 from 1st column

with(pcaData,{
  scatter3d(PC1, PC2, PC3, surface=F, groups = ID, ellipsoid = T,  grid = F,
            axis.scales = T,
            xlim = c(minScale, maxScale),
            ylim = c(minScale, maxScale),
            zlim = c(minScale, maxScale),
            xlab = "PC-1", 
            ylab = "PC-2",
            zlab = "PC-3")
})
    

基于上述,我希望所有三个轴都跨越一个共同的范围。我认为这xlim = c(low, high)会起作用,但它不被认可。

任何帮助,将不胜感激。

干杯。

4

0 回答 0