简体   繁体   English

Plotly:如何在 3D plot 中为相机视图设置手动变焦?

[英]Plotly: How to set manual zoom for camera view in a 3D plot?

I use the data below to create a 3D plot but I cannot get the full axis to show.我使用下面的数据来创建 3D plot 但我无法显示完整的轴。 Can I set the original zoom so that it shows the entire plot?我可以设置原始缩放以显示整个 plot 吗?

> dput(analysis[,c(1:3)])
structure(list(L = c(60, 70, 80, 90, 100, 110, 120, 130, 140, 
60, 70, 80, 90, 100, 110, 120, 130, 140, 60, 70, 80, 90, 100, 
110, 120, 130, 140, 60, 70, 80, 90, 100, 110, 120, 130, 140), 
    S = c(6, 6, 6, 6, 6, 6, 6, 6, 6, 7.5, 7.5, 7.5, 7.5, 7.5, 
    7.5, 7.5, 7.5, 7.5, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10.5, 10.5, 
    10.5, 10.5, 10.5, 10.5, 10.5, 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)))

Below is a screenshot of the HTML output:下面是 HTML output 的截图:

在此处输入图像描述

You'll have to find a combination of x, y, and z in scene = list(camera = list(eye = list(x=1.5, y=3, z = 0.1))) that suits your needs.您必须在scene = list(camera = list(eye = list(x=1.5, y=3, z = 0.1)))中找到适合您需要的x, y, and z组合。

Your code snippet is not reproducible, but we can recreate the problem using:您的代码片段不可重现,但我们可以使用以下方法重现问题:

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

在此处输入图像描述

Now, just include:现在,只需包括:

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

And you'll get:你会得到:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM