情节:如何在3D图中为相机视图设置手动缩放?

问题描述

我使用下面的数据创建3D图,但无法显示完整的轴。我可以设置原始缩放比例以显示整个图吗?

> dput(analysis[,c(1:3)])
structure(list(L = c(60,70,80,90,100,110,120,130,140,60,140),S = c(6,6,7.5,9,10.5,10.5),theta = c(0.387648377238727,0.365065109815399,0.361945691353903,0.308994736435413,0.31312106684787,0.347902392899031,0.322177548286843,0.313365432864246,0.318566760330453,0.329343960085812,0.4305266050694,0.412161930763136,0.405615100181224,0.342671510183088,0.379821799998522,0.351607159033827,0.338622255013142,0.330437773555393,0.359828622589832,0.43564477128519,0.446968516154636,0.364471191945187,0.311372659889749,0.343410820556976,0.319743944825857,0.367342095248675,0.303374120182854,0.402025212310935,0.486427167733943,0.402463557214462,0.380560495098558,0.32606222794188,0.383477501221339,0.315207079133179,0.359243336292084,0.338734658604223)),class = "data.frame",row.names = c(NA,-36L))


fig <- plot_ly(analysis,x = ~L,y = ~S,z = ~theta) %>% 
  add_markers(opacity = 0.6) %>% 
  layout(scene = list(xaxis = list(title = 'Span Length (ft)'),yaxis = list(title = 'Girder Spacing (ft)'),zaxis = list(title = 'End Rotation (deg)')),margin = list(b=130),annotations = 
 list(x = 0.9,y = -0.2,text = "<i>Figure 4.  Relationship between the input variables used in the parametric study.</i>",showarrow = F,xref='paper',yref='paper',xanchor='right',yanchor='auto',xshift=0,yshift=0,font=list(size=15)))

下面是HTML输出的屏幕截图:

enter image description here

解决方法

您必须在x,y,and z中找到满足您需要的scene = list(camera = list(eye = list(x=1.5,y=3,z = 0.1)))组合。

您的代码段不可复制,但是我们可以使用以下方法重新创建问题:

fig <- plot_ly(z = ~volcano)
fig <- fig %>% add_surface()
fig

enter image description here

现在,只需包括:

scene = list(camera = list(eye = list(x=1.5,z = 0.1)))
fig <- fig  %>% layout(title = "changed zoom",scene = scene)

您将得到:

enter image description here

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...