如何使用 R rgl 3D 图获得大小相等的轴

How can I get equal sized axes with R rgl 3D plots

我正在使用 rgl-package 绘制 3D 点图

par(mar = c(0, 0, 0, 0), cex.lab=1)
plot3d(cart$x,cart$y,cart$z,"X","Y","Z")

到目前为止这项工作。由于值的不同,只有 3 轴的大小不同。

我需要相同尺寸的轴。

这是当前输出。 所有 3 个轴都应该转到 10000,或者我设置的任何值。

我怎样才能做到这一点?

(据我所知,xlim 等不起作用)

我想你想要aspect3d(1,1,1)(虽然没有给出可重现的例子)

来自?aspect3d

aspect3d(x, y = NULL, z = NULL)
If the ratios are all 1, the bounding box will be displayed as a cube approximately filling the display. Values may be set larger or smaller as desired.

我终于通过在轴的末端添加三个点解决了这个挑战。

endpoints <- read.table(header = TRUE, text = "
       x  y z
       -11000  0   0
       0  -11000 0
       0  0 11000
       ")
cart <- rbind(cart, endpoints)
plot3d(cart$x,cart$y,cart$z,"X","Y","Z")

也许不是最优雅的解决方案,但它对我有用。