gpt4 book ai didi

r - 如何在R中指定3d绘图图表的相机视角?

转载 作者:行者123 更新时间:2023-12-04 09:13:06 24 4
gpt4 key购买 nike

我想更改我的3d散点图的默认相机视角,但从帮助中尚不清楚如何完成此操作。我知道布局参数应包含在命名列表中,但不能使它适用于“眼睛”,“向上”和“中央”相机参数。

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)

最佳答案

这有点晚了,但希望这可以帮助其他人寻求解决方案。这是一个例子:

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)

关于r - 如何在R中指定3d绘图图表的相机视角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34178381/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com