简体   繁体   中英

R Plotly: 3D surface reverse x-axis

I am trying to setup the camera of a 3D surface plot such that the x axis goes from from left = 0 to right = 60, and the y axis from bottom = 0 to top = 80, while having the z axis on the left side.

There goes an example:

library(plotly)
library(magrittr)

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

This is the default output:
在此处输入图片说明

This is what I want:
在此处输入图片说明

I tried to change the x , y , and z parameters from the eye() function without success. I also tried to use xasix = list(autoarante = "reversed") .

The eye vector determines the position of the camera, with a default of (x = 1.25, y = 1.25, z = 1.25).

To change the default to get the desired perspective, you can set the y in the camera eye to a negative value.

library(plotly)
library(magrittr)

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

Output

带有相机眼睛的火山的情节图在布局上发生了变化

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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