简体   繁体   English

R scatterplot3d 绘制坐标不正确的点

[英]R scatterplot3d plotting points with incorrect coordinates

The scatterplot3D function seems to be plotting incorrectly and I am unsure about why. scatterplot3D function 似乎绘制不正确,我不确定为什么。 For example, the following commands should yield identical plots but they do not.例如,以下命令应该产生相同的图,但它们不会。 I also providing reproducible code to create the data structures below.我还提供了可重现的代码来创建下面的数据结构。 I guess it is not correctly processing my input?我猜它没有正确处理我的输入?

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)

Now I try to plot现在我尝试 plot

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

plot of new.cent with cent added as points in different format new.cent 的 plot 以不同格式添加分作为点

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

plot of cent with new.cent added as points in different format分的 plot 和 new.cent 添加为不同格式的点

The above points don't seem correct in any case... Moreover, if I try to add a single point as in "points(cent[1,])" it adds three points which is also indicative of the malfunction.在任何情况下,上述几点似乎都不正确......此外,如果我尝试像“points(cent [1,])”一样添加一个点,它会添加三个点,这也表示故障。

Please refer to linked manual, how to add points3d to the plot.请参阅链接手册,如何将points3d添加到 plot。 Also, to compare plots, please make sure they axes limits are the same.此外,要比较图,请确保它们的轴限制相同。

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)

Created on 2022-01-27 by the reprex package (v2.0.1)代表 package (v2.0.1) 于 2022 年 1 月 27 日创建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM