如何在 R 中指定 3d 图表的相机视角?
How to specify camera perspective of 3d plotly chart in R?
我想更改我的 plotly 3d 散点图的默认相机视角,从帮助中不清楚应该如何完成。我了解布局参数应包含在命名列表中,但无法使其适用于 'eye' 'up' 和 'center' 相机参数。
https://plot.ly/r/reference/#layout-scene-camera
应该是这样的:
require(plotly)
scene=list(bgcolor='#990055',camera=list(eye=c(1,2,3)))
plot_ly(x=rnorm(100), y=rnorm(100), z=rnorm(100),
type="scatter3d", mode='markers+lines') %>% layout(scene=scene)
在python中,我这样设置默认相机:
scene=dict(cameraposition=[[-0.1, 0.5, -0.7, -0.2], [0.0, 0, 0.0], 2.8])
前 4 个数字是旋转,接下来的 3 个是 x,y,z 平移,最后一个数字是缩放。我也很难找到文档;这是我发现的最好的:
https://plot.ly/python/3d-plots-tutorial/#in-[7]
这有点晚了,但希望这能帮助其他人寻找解决方案。这是一个例子:
library(plotly)
set.seed(123)
# Create Random Data
ds <- diamonds[sample(1:nrow(diamonds), size = 1000),]
scene = list(camera = list(eye = list(x = -1.25, y = 1.25, z = 1.25)))
plot_ly(ds, x = carat, y = cut, z = price, group = color, type = "scatter3d", mode = "markers",
marker = list(opacity = 0.6, size = 4)) %>%
layout(title = "3D Scatter plot", scene = scene)
我想更改我的 plotly 3d 散点图的默认相机视角,从帮助中不清楚应该如何完成。我了解布局参数应包含在命名列表中,但无法使其适用于 'eye' 'up' 和 'center' 相机参数。
https://plot.ly/r/reference/#layout-scene-camera
应该是这样的:
require(plotly)
scene=list(bgcolor='#990055',camera=list(eye=c(1,2,3)))
plot_ly(x=rnorm(100), y=rnorm(100), z=rnorm(100),
type="scatter3d", mode='markers+lines') %>% layout(scene=scene)
在python中,我这样设置默认相机:
scene=dict(cameraposition=[[-0.1, 0.5, -0.7, -0.2], [0.0, 0, 0.0], 2.8])
前 4 个数字是旋转,接下来的 3 个是 x,y,z 平移,最后一个数字是缩放。我也很难找到文档;这是我发现的最好的: https://plot.ly/python/3d-plots-tutorial/#in-[7]
这有点晚了,但希望这能帮助其他人寻找解决方案。这是一个例子:
library(plotly)
set.seed(123)
# Create Random Data
ds <- diamonds[sample(1:nrow(diamonds), size = 1000),]
scene = list(camera = list(eye = list(x = -1.25, y = 1.25, z = 1.25)))
plot_ly(ds, x = carat, y = cut, z = price, group = color, type = "scatter3d", mode = "markers",
marker = list(opacity = 0.6, size = 4)) %>%
layout(title = "3D Scatter plot", scene = scene)