0

scatterplot3D 函数似乎绘制不正确,我不确定原因。例如,以下命令应该产生相同的图,但它们不会。我还提供了可重现的代码来创建下面的数据结构。我猜它没有正确处理我的输入?

install.packages("scatterplot3d")
library("scatterplot3d")
cent = array(dim=c(4,3))
cll = c("Factor1", "Factor2", "Factor3")
colnames(cent) = cll
cent[1,] = c(-0.25320707, -0.5878291, -0.4522262)
cent[2,] = c(2.49368231, 0.5911989, -0.3728652)
cent[3,] = c(-0.02927063, -0.2627355, 1.6147719)
cent[4,] = c(-0.63391974, 1.0109955, -0.1542808)

new.cent = array(dim=c(4,3))
colnames(new.cent) = cll
new.cent[1,] = c(2.1572533, 0.4985594, -0.1989068)
new.cent[2,] = c(-0.1362396, -0.4134629, 1.2677813)
new.cent[3,] = c(-0.2566698, -0.6602819, -0.5245323)
new.cent[4,] = c(-0.5847768, 0.7672588, -0.1918044)

现在我尝试绘制

plot.new()
scatterplot3d(new.cent, pch = 10)
points(cent, pch = 3)

new.cent 的图,其中 cent 添加为不同格式的点

plot.new()
scatterplot3d(cent, pch = 3)
points(new.cent, pch = 10)

以不同格式添加 new.cent 作为点的分图

在任何情况下,上述几点似乎都不正确......此外,如果我尝试像“points(cent [1,])”那样添加一个点,它会添加三个点,这也表明故障。

4

1 回答 1

0

请参阅链接手册,如何添加points3d到情节。此外,要比较图,请确保它们的轴限制相同。

library("scatterplot3d")
cent = array(dim=c(4,3))
cll = c("Factor1", "Factor2", "Factor3")
colnames(cent) = cll
cent[1,] = c(-0.25320707, -0.5878291, -0.4522262)
cent[2,] = c(2.49368231, 0.5911989, -0.3728652)
cent[3,] = c(-0.02927063, -0.2627355, 1.6147719)
cent[4,] = c(-0.63391974, 1.0109955, -0.1542808)

new.cent = array(dim=c(4,3))
colnames(new.cent) = cll
new.cent[1,] = c(2.1572533, 0.4985594, -0.1989068)
new.cent[2,] = c(-0.1362396, -0.4134629, 1.2677813)
new.cent[3,] = c(-0.2566698, -0.6602819, -0.5245323)
new.cent[4,] = c(-0.5847768, 0.7672588, -0.1918044)


plot.new()
a <- scatterplot3d(new.cent, pch = 10, xlim = c(-1,2.5), ylim = c(-1,1.5), zlim = c(-1,2))
a$points3d(cent, pch = 3)

b <- scatterplot3d(cent, pch = 3, xlim = c(-1,2.5), ylim = c(-1,1.5), zlim = c(-1,2))
b$points3d(new.cent, pch = 10)

reprex 包于 2022-01-27 创建(v2.0.1)

于 2022-01-27T19:26:29.233 回答