在R中用plot_ly保持3dplot的相同视图

时间:2016-07-18 20:18:39

标签: r view camera plotly

我有这个数据集:

> readData

   time             X             Y             Z
1     0        0.0000        0.0000        0.0000
2    29        0.2179       -0.0952        9.9940
3  1028        0.2185       -0.0748        9.9599
4  2029        0.2269       -0.0958        9.9623
5  3029        0.2598       -0.0275       10.1053
6  4029       -0.3154        5.1272        8.3127
7  5029        0.2107        9.5942        1.7274
8  6029       -0.7213        9.8049        1.2252
9  7029       -0.0198        9.1494       -3.3776
10 8029       -0.2472        6.0543       -7.5669

我想绘制每行输出相同视图的矢量(X,Y,Z)。

基于上一个问题:How to specify camera perspective of 3d plotly chart in R?

以下是我的尝试:

for (ind in 1:length(readData)
{
  x <- c(0, readData$X[ind])
  y <- c(0, readData$Y[ind])
  z <- c(0, readData$Z[ind])
  scene = list(camera = list(eye = list(x=2, y=2, z=0.1), center=list(x=0, y=0, z=0), up=list(x=0, y=0, z=1)))
  p <- plot_ly(x=x, y=y, z=z, type="scatter3d") %>% 
    layout(title = "3D Scatter plot", scene = scene)
  print(p)
  Sys.sleep(1)
}

不幸的是,我仍然最终对我的情节有不同的相机视图。

我在这里缺少什么?

感谢您的帮助。

0 个答案:

没有答案
相关问题