R中3D图形的正交投影(Plotly)

3

我正在尝试使用plotly绘制一些3D数据,但是我不想要默认的透视效果,而是寻找正交投影(即较远的点之间的距离不会变小)。我已经尝试更改layout.scene.camera参数projection(请参见下面提供的示例数据代码),但没有成功。我希望能得到如何实现这一点的任何建议。

fig2 <- plot_ly(iris,x =~Sepal.Length, y=~Sepal.Width, z=~Petal.Length,  
              marker = list(size = 2),  color = ~Petal.Width) %>% 
              layout(scene = list(camera =list(projection='orthographic'),
            aspectmode = "manual", aspectratio = list(x=1, y=5,z=0.5)))%>% 
            add_markers()

@Peter,这是“鸢尾花”数据集。 - CubicInfinity
1个回答

1

您只需要将投影值放在一个命名列表中即可。参考:https://plotly.com/r/reference/layout/scene/#layout-scene-camera-projection

使用projection=list(type = 'orthographic')替换projection='orthographic'

plot_ly(iris, x = ~Sepal.Length, y = ~Sepal.Width, z = ~Petal.Length,  
        marker = list(size = 2), color = ~Petal.Width) %>% 
  layout(
    scene = list(camera = list(projection = list(type = 'orthographic')), 
    aspectmode = "manual", 
    aspectratio = list(x=1, y=5,z=0.5))
    ) %>% 
  add_markers()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接