【问题标题】:R Plotly: 3D surface reverse x-axisR Plotly:3D 曲面反向 x 轴
【发布时间】:2021-02-23 09:06:17
【问题描述】:

我正在尝试设置 3D 曲面图的相机,使 x 轴从左 = 0 到右 = 60,y 轴从底部 = 0 到顶部 = 80,同时打开 z 轴左边。

举个例子:

library(plotly)
library(magrittr)

plot_ly(z = ~volcano) %>%
  add_surface() %>%
  layout(scene = list(camera=list()))

这是默认输出:

这就是我想要的:

我尝试更改eye() 函数中的xyz 参数,但没有成功。我也尝试使用xasix = list(autoarante = "reversed")

【问题讨论】:

  • 我尝试为camera 更改eye 参数,例如:camera=list(eye = list(x = .5, y = -2, z = 1.25)) 它似乎接近您想要的情节?你怎么看?
  • @Ben 它有效!不知道您可以为eye 设置负值。发表你的答案,我会接受的。

标签: r plotly r-plotly


【解决方案1】:

eye 向量确定相机的位置,默认为 (x = 1.25, y = 1.25, z = 1.25)。

要更改默认值以获得所需的透视,您可以将camera 中的y 设置为负值。

library(plotly)
library(magrittr)

plot_ly(z = ~volcano) %>%
  add_surface() %>%
  layout(scene = list(camera=list(eye = list(x = .8, y = -2, z = 1.25))))

输出

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-08
    • 2018-05-06
    • 1970-01-01
    • 2017-10-31
    • 2016-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多