如何在R中指定3d绘图图表的相机视角? [英] How to specify camera perspective of 3d plotly chart in R?

查看:53
本文介绍了如何在R中指定3d绘图图表的相机视角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to change the default camera perspective of my plotly 3d scatter plot, it is not clear from the help how this should be done. I understand the layout parameters should be included in a named list but cannot get it to work for the 'eye' 'up' and 'center' camera parameters.

https://plot.ly/r/reference/#layout-scene-相机

应该是这样的:

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)

推荐答案

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

This is a little late but hopefully this helps others looking for a solution to this. Here's an example:

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中指定3d绘图图表的相机视角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆