将3dplot的视图与R中的plot_y保持一致
我有以下数据集:将3dplot的视图与R中的plot_y保持一致,r,view,camera,plotly,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
> 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)
基于上一个问题:
以下是我尝试过的:
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)
}
for(ind in 1:length(readData)
{
在readData$x[ind]中,什么是“ind”?我在数据帧的行上迭代。“ind”是我的for循环的索引,用于访问行ind处每列的元素。